mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
More leak fixes
This commit is contained in:
parent
d68e8be8ee
commit
5b46efa8cd
14 changed files with 65 additions and 55 deletions
|
@ -131,6 +131,7 @@ NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts)
|
|||
exp = [NSException exceptionWithName: NSInvalidArgumentException
|
||||
reason: @"nil argument"
|
||||
userInfo: nil];
|
||||
RELEASE(self);
|
||||
[exp raise];
|
||||
}
|
||||
|
||||
|
@ -961,10 +962,9 @@ prepareResult(NSRegularExpression *regex,
|
|||
return nil;
|
||||
}
|
||||
utext_clone(&ret->txt, output, TRUE, TRUE, &s);
|
||||
uregex_close(r);
|
||||
|
||||
utext_close(&txt);
|
||||
utext_close(output);
|
||||
uregex_close(r);
|
||||
utext_close(&txt);
|
||||
utext_close(&replacement);
|
||||
return AUTORELEASE(ret);
|
||||
}
|
||||
|
|
|
@ -658,14 +658,17 @@ static NSUInteger urlAlign;
|
|||
isDirectory: (BOOL)isDir
|
||||
relativeToURL: (NSURL *)baseURL
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
BOOL flag = NO;
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
BOOL flag = NO;
|
||||
|
||||
if (nil == aPath)
|
||||
{
|
||||
NSString *name = NSStringFromClass([self class]);
|
||||
|
||||
RELEASE(self);
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@ %@] nil string parameter",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
name, NSStringFromSelector(_cmd)];
|
||||
}
|
||||
if ([aPath isAbsolutePath] == NO)
|
||||
{
|
||||
|
@ -803,16 +806,22 @@ static NSUInteger urlAlign;
|
|||
}
|
||||
if ([aUrlString isKindOfClass: [NSString class]] == NO)
|
||||
{
|
||||
NSString *name = NSStringFromClass([self class]);
|
||||
|
||||
RELEASE(self);
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@ %@] bad string parameter",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
name, NSStringFromSelector(_cmd)];
|
||||
}
|
||||
if (aBaseUrl != nil
|
||||
&& [aBaseUrl isKindOfClass: [NSURL class]] == NO)
|
||||
{
|
||||
NSString *name = NSStringFromClass([self class]);
|
||||
RELEASE(self);
|
||||
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@ %@] bad base URL parameter",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
name, NSStringFromSelector(_cmd)];
|
||||
}
|
||||
ASSIGNCOPY(_urlString, aUrlString);
|
||||
ASSIGN(_baseURL, [aBaseUrl absoluteURL]);
|
||||
|
@ -2301,14 +2310,14 @@ static NSCharacterSet *queryItemCharSet = nil;
|
|||
// Creating URL components...
|
||||
+ (instancetype) componentsWithString: (NSString *)urlString
|
||||
{
|
||||
return AUTORELEASE([[NSURLComponents alloc] initWithString: urlString]);
|
||||
return AUTORELEASE([[NSURLComponents alloc] initWithString: urlString]);
|
||||
}
|
||||
|
||||
+ (instancetype) componentsWithURL: (NSURL *)url
|
||||
resolvingAgainstBaseURL: (BOOL)resolve
|
||||
{
|
||||
return AUTORELEASE([[NSURLComponents alloc] initWithURL: url
|
||||
resolvingAgainstBaseURL: resolve]);
|
||||
return AUTORELEASE([[NSURLComponents alloc] initWithURL: url
|
||||
resolvingAgainstBaseURL: resolve]);
|
||||
}
|
||||
|
||||
- (instancetype) init
|
||||
|
@ -2342,6 +2351,7 @@ static NSCharacterSet *queryItemCharSet = nil;
|
|||
}
|
||||
else
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
ENTER_POOL
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
|
||||
[dict setObject:@"value" forKey:@"key"];
|
||||
NSProgress *progress = [[NSProgress alloc] initWithParent: nil
|
||||
userInfo: dict];
|
||||
NSProgress *progress = AUTORELEASE([[NSProgress alloc] initWithParent: nil
|
||||
userInfo: dict]);
|
||||
PASS(progress != nil,
|
||||
"[NSProgress initWithParent:userInfo:] returns instance");
|
||||
|
||||
|
@ -42,14 +43,14 @@ int main()
|
|||
NSProgress *new_progress = [NSProgress progressWithTotalUnitCount:100
|
||||
parent:progress
|
||||
pendingUnitCount:50];
|
||||
[new_progress addChild:[[NSProgress alloc] initWithParent: nil userInfo: nil]
|
||||
withPendingUnitCount:50];
|
||||
[new_progress addChild: AUTORELEASE([[NSProgress alloc]
|
||||
initWithParent: nil userInfo: nil]) withPendingUnitCount:50];
|
||||
|
||||
[currentProgress resignCurrent];
|
||||
|
||||
PASS([NSProgress currentProgress] == nil,
|
||||
"Current progress is nil after resign current");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
LEAVE_POOL
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ int main()
|
|||
|
||||
theClass = [NSProxy class];
|
||||
PASS(theClass != Nil, "%s exists",prefix);
|
||||
obj0 = [NSProxy alloc];
|
||||
obj0 = AUTORELEASE([NSProxy alloc]);
|
||||
PASS(obj0 != nil, "%s has working alloc",prefix);
|
||||
PASS_EXCEPTION([obj0 isKindOfClass:theClass];, NSInvalidArgumentException,
|
||||
"NSProxy -isKindOfClass raises exception");
|
||||
|
@ -25,7 +25,7 @@ int main()
|
|||
NSInvalidArgumentException,
|
||||
"NSProxy -isKindOfClass raises exception");
|
||||
|
||||
obj1 = [NSProxy allocWithZone:testZone];
|
||||
obj1 = AUTORELEASE([NSProxy allocWithZone:testZone]);
|
||||
PASS(obj1 != nil, "%s has working allocWithZone:",prefix);
|
||||
#ifndef OBJC_CAP_ARC
|
||||
PASS(NSZoneFromPointer(obj1) == testZone, "%s uses zone for alloc",prefix);
|
||||
|
|
|
@ -74,10 +74,12 @@ int main()
|
|||
id sub = @"Remote";
|
||||
|
||||
PASS(theClass == [NSProxy class], "uses +class to return self");
|
||||
PASS([[NSProxy alloc] isProxy] == YES,
|
||||
obj = [NSProxy alloc];
|
||||
PASS([obj isProxy] == YES,
|
||||
"%s implements -isProxy to return YES",prefix);
|
||||
PASS([[NSProxy alloc] description] != nil, "%s implements -description",prefix);
|
||||
obj = [[MyProxy alloc] init];
|
||||
PASS([obj description] != nil, "%s implements -description",prefix);
|
||||
RELEASE(obj);
|
||||
obj = AUTORELEASE([[MyProxy alloc] init]);
|
||||
PASS(obj != nil, "Can create a MyProxy instance");
|
||||
PASS([obj isEqual: obj], "proxy isEqual: to self without remote");
|
||||
[obj setRemote: rem];
|
||||
|
|
|
@ -188,7 +188,7 @@ main(int argc, char *argv[])
|
|||
NSRange r0;
|
||||
NSRange r1;
|
||||
|
||||
obj = [[MyProxy alloc] init];
|
||||
obj = AUTORELEASE([[MyProxy alloc] init]);
|
||||
[obj setRemote:rem];
|
||||
|
||||
[obj voidPvoid]; //shoudn't raise
|
||||
|
|
|
@ -69,15 +69,12 @@ int main()
|
|||
[dflts setVolatileDomain: domain
|
||||
forName: @"GSTestDomain"];
|
||||
# endif
|
||||
id testObj = [[NSRegularExpression alloc] initWithPattern: @"^a"
|
||||
options: 0
|
||||
error: NULL];
|
||||
id testObj = AUTORELEASE([[NSRegularExpression alloc]
|
||||
initWithPattern: @"^a" options: 0 error: NULL]);
|
||||
|
||||
test_NSObject(@"NSRegularExpression",
|
||||
[NSArray arrayWithObject:
|
||||
[[NSRegularExpression alloc] initWithPattern: @"^a"
|
||||
options: 0
|
||||
error: NULL]]);
|
||||
[NSArray arrayWithObject: AUTORELEASE([[NSRegularExpression
|
||||
alloc] initWithPattern: @"^a" options: 0 error: NULL])]);
|
||||
test_NSCopying(@"NSRegularExpression",@"NSRegularExpression",
|
||||
[NSArray arrayWithObject:testObj],NO,NO);
|
||||
|
||||
|
@ -138,10 +135,8 @@ int main()
|
|||
PASS_EQUAL(replacement, @"c",
|
||||
"Custom replacement: Returns correct replacement");
|
||||
|
||||
NSRegularExpression *testObj2 =
|
||||
[[NSRegularExpression alloc] initWithPattern: @"bc"
|
||||
options: 0
|
||||
error: NULL];
|
||||
NSRegularExpression *testObj2 = AUTORELEASE([[NSRegularExpression alloc]
|
||||
initWithPattern: @"bc" options: 0 error: NULL]);
|
||||
r = [testObj2 firstMatchInString: @"abcdeabcde"
|
||||
options: 0
|
||||
range: NSMakeRange(5, 5)];
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
id testObj;
|
||||
ENTER_POOL
|
||||
id testObj;
|
||||
|
||||
PASS([NSRunLoop new] == nil, "run loop initialises to nil");
|
||||
testObj = [NSRunLoop currentRunLoop];
|
||||
test_NSObject(@"NSRunLoop", [NSArray arrayWithObject:testObj]);
|
||||
test_NSObject(@"NSRunLoop", [NSArray arrayWithObject: testObj]);
|
||||
|
||||
PASS([NSTimer new] == nil, "timer initialises to nil");
|
||||
ASSIGN(testObj, [[NSTimer alloc] initWithFireDate: 0 interval: 0 target: [NSObject class] selector: @selector(description) userInfo: nil repeats: NO]);
|
||||
test_NSObject(@"NSTimer", [NSArray arrayWithObject:testObj]);
|
||||
PASS(AUTORELEASE([NSTimer new]) == nil, "timer initialises to nil");
|
||||
testObj = AUTORELEASE([[NSTimer alloc] initWithFireDate: 0 interval: 0 target: [NSObject class] selector: @selector(description) userInfo: nil repeats: NO]);
|
||||
test_NSObject(@"NSTimer", [NSArray arrayWithObject: testObj]);
|
||||
|
||||
[arp release]; arp = nil;
|
||||
LEAVE_POOL
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ const NSTimeInterval kDelay = 0.01;
|
|||
- (void) run
|
||||
{
|
||||
NSDate *until = [NSDate dateWithTimeIntervalSinceNow: 1.0];
|
||||
Counter *c = [Counter new];
|
||||
Counter *c = AUTORELEASE([Counter new]);
|
||||
[NSTimer scheduledTimerWithTimeInterval: 1.0
|
||||
target: self
|
||||
selector: @selector(timeout:)
|
||||
|
|
|
@ -49,7 +49,7 @@ int main()
|
|||
PASS(scanThreeWords(str,charSet),
|
||||
"scanning three words separated by newlines and spaces");
|
||||
|
||||
charSet = [charSet mutableCopy];
|
||||
charSet = AUTORELEASE([charSet mutableCopy]);
|
||||
[charSet addCharactersInString:@";"];
|
||||
str = @"one ;two ;three ;";
|
||||
PASS(scanThreeWords(str,charSet),
|
||||
|
|
|
@ -6,9 +6,9 @@ int main()
|
|||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSSet *testObj;
|
||||
NSMutableArray *testObjs = [NSMutableArray new];
|
||||
NSMutableArray *testObjs = [NSMutableArray array];
|
||||
|
||||
testObj = [NSSet new];
|
||||
testObj = [NSSet set];
|
||||
[testObjs addObject:testObj];
|
||||
PASS(testObj != nil && [testObj count] == 0,
|
||||
"can create an empty set");
|
||||
|
|
|
@ -18,7 +18,7 @@ int main()
|
|||
NSArray *a2;
|
||||
NSArray *a3;
|
||||
|
||||
s1 = [[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES];
|
||||
s1 = [NSSortDescriptor sortDescriptorWithKey: @"name" ascending: YES];
|
||||
PASS(s1 != nil, "can create a sort descriptor");
|
||||
|
||||
array = [NSArray arrayWithObject: s1];
|
||||
|
@ -27,9 +27,9 @@ int main()
|
|||
test_keyed_NSCoding(array);
|
||||
test_NSCopying(@"NSSortDescriptor", @"NSSortDescriptor", array, NO, NO);
|
||||
|
||||
s2 = [[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES];
|
||||
s3 = [[NSSortDescriptor alloc] initWithKey: @"other" ascending: YES];
|
||||
s4 = [[NSSortDescriptor alloc] initWithKey: @"other" ascending: NO];
|
||||
s2 = [NSSortDescriptor sortDescriptorWithKey: @"name" ascending: YES];
|
||||
s3 = [NSSortDescriptor sortDescriptorWithKey: @"other" ascending: YES];
|
||||
s4 = [NSSortDescriptor sortDescriptorWithKey: @"other" ascending: NO];
|
||||
PASS([s1 hash] == [s2 hash], "hash for similar descriptors is the same");
|
||||
PASS([s1 isEqual: s2], "similar descriptors are equal");
|
||||
PASS(![s1 isEqual: s3], "different keyed descriptors are not equal");
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSArray *testObj = [NSTask new];
|
||||
ENTER_POOL
|
||||
NSArray *testObj = AUTORELEASE([NSTask new]);
|
||||
|
||||
test_NSObject(@"NSTask", [NSArray arrayWithObject:testObj]);
|
||||
test_NSObject(@"NSTask", [NSArray arrayWithObject: testObj]);
|
||||
|
||||
[arp release]; arp = nil;
|
||||
LEAVE_POOL
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ int main()
|
|||
unichar u = 163;
|
||||
unichar buf[256];
|
||||
|
||||
TEST_FOR_CLASS(@"NSURL", [NSURL alloc],
|
||||
TEST_FOR_CLASS(@"NSURL", AUTORELEASE([NSURL alloc]),
|
||||
"NSURL +alloc returns an NSURL");
|
||||
|
||||
TEST_FOR_CLASS(@"NSURL", [NSURL fileURLWithPath: @"."],
|
||||
|
@ -366,16 +366,18 @@ GSPathHandling("right");
|
|||
NSURLQueryItem* item = [[NSURLQueryItem alloc] init];
|
||||
PASS_EQUAL(item.name, @"", "NSURLQueryItem.name should not be nil");
|
||||
PASS_EQUAL(item.value, nil, "NSURLQueryItem.value should be nil");
|
||||
RELEASE(item);
|
||||
|
||||
//OSX behavior is to return query item with an empty string name
|
||||
item = [[NSURLQueryItem alloc] initWithName:nil value:nil];
|
||||
PASS_EQUAL(item.name, @"", "NSURLQueryItem.name should not be nil");
|
||||
PASS_EQUAL(item.value, nil, "NSURLQueryItem.value should be nil");
|
||||
RELEASE(item);
|
||||
|
||||
item = [[NSURLQueryItem alloc] initWithName:@"myName" value:@"myValue"];
|
||||
PASS_EQUAL(item.name, @"myName", "NSURLQueryItem.name should not be nil");
|
||||
PASS_EQUAL(item.value, @"myValue", "NSURLQueryItem.value should not be nil");
|
||||
|
||||
RELEASE(item);
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue