Make -drain and -release in NSAutoreleasePool do the same thing (rather than one calling the other) in non-GC mode.

Replace all -release messages sent to autorelease pools with -drain.  In non-GC mode, these are equivalent.  In GC mode, these trigger a collection.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33143 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2011-05-27 11:48:44 +00:00
parent 3dd46a1d8c
commit e50e12129e
28 changed files with 61 additions and 59 deletions

View file

@ -6033,7 +6033,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
[md appendData: d]; [md appendData: d];
} }
} }
[arp release]; [arp drain];
return md; return md;
} }
@ -6195,7 +6195,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
[self setContent: newContent]; [self setContent: newContent];
[self setHeader: hdr]; [self setHeader: hdr];
[arp release]; [arp drain];
} }
/** /**
@ -6222,7 +6222,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
format: @"Unable to parse type information"]; format: @"Unable to parse type information"];
} }
[self setHeader: hdr]; [self setHeader: hdr];
[arp release]; [arp drain];
} }
/** /**

View file

@ -2009,7 +2009,7 @@ GSPrintf (FILE *fptr, NSString* format, ...)
ok = YES; ok = YES;
} }
} }
[arp release]; [arp drain];
return ok; return ok;
} }

View file

@ -72,7 +72,7 @@
minutes: 0 minutes: 0
seconds: 0]; seconds: 0];
dayOfYear = [thursday dayOfYear]; dayOfYear = [thursday dayOfYear];
[arp release]; [arp drain];
} }
else else
{ {

View file

@ -152,7 +152,7 @@
DESTROY(self); DESTROY(self);
} }
NSZoneFree(NSDefaultMallocZone(), dst); NSZoneFree(NSDefaultMallocZone(), dst);
[arp release]; [arp drain];
if (self == nil) if (self == nil)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException

View file

@ -465,7 +465,9 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
- (void) drain - (void) drain
{ {
[self release]; // Don't call -release, make both -release and -drain have the same cost in
// non-GC mode.
[self dealloc];
} }
- (id) retain - (id) retain

View file

@ -1976,7 +1976,7 @@ IF_NO_GC(
} }
} }
[result retain]; [result retain];
[arp release]; [arp drain];
return [result autorelease]; return [result autorelease];
} }

View file

@ -721,7 +721,7 @@ static NSLock *cached_proxies_gate = nil;
{ {
proxy = [[connection rootProxy] retain]; proxy = [[connection rootProxy] retain];
} }
[arp release]; [arp drain];
return [proxy autorelease]; return [proxy autorelease];
} }
@ -749,7 +749,7 @@ static NSLock *cached_proxies_gate = nil;
{ {
proxy = RETAIN([connection rootProxy]); proxy = RETAIN([connection rootProxy]);
} }
[arp release]; [arp drain];
return AUTORELEASE(proxy); return AUTORELEASE(proxy);
} }
@ -1314,7 +1314,7 @@ static NSLock *cached_proxies_gate = nil;
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName: NSConnectionDidDieNotification postNotificationName: NSConnectionDidDieNotification
object: self]; object: self];
[arp release]; [arp drain];
} }
/* /*
@ -1954,7 +1954,7 @@ static NSLock *cached_proxies_gate = nil;
DESTROY(IrefGate); DESTROY(IrefGate);
[arp release]; [arp drain];
} }
/* /*

View file

@ -1188,7 +1188,7 @@ GSPrivateStackAddresses(void)
signal(SIGBUS, env->bus); signal(SIGBUS, env->bus);
} }
#endif #endif
[pool release]; [pool drain];
return stack; return stack;
} }

View file

@ -743,7 +743,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
rootProxyForConnectionWithRegisteredName: service rootProxyForConnectionWithRegisteredName: service
host: host usingNameServer: ns]; host: host usingNameServer: ns];
[_remote retain]; [_remote retain];
[pool release]; [pool drain];
} }
if (_remote == nil) if (_remote == nil)
{ {

View file

@ -771,7 +771,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
[[[exception _callStack] description] lossyCString]); [[[exception _callStack] description] lossyCString]);
} }
fflush(stderr); /* NEEDED UNDER MINGW */ fflush(stderr); /* NEEDED UNDER MINGW */
[pool release]; [pool drain];
_terminate(); _terminate();
} }
@ -947,7 +947,7 @@ callUncaughtHandler(id value)
[super description], _e_name, _e_reason]; [super description], _e_name, _e_reason];
} }
[result retain]; [result retain];
[pool release]; [pool drain];
return [result autorelease]; return [result autorelease];
} }

View file

@ -681,7 +681,7 @@ static NSStringEncoding defaultEncoding;
{ {
ok = [self contentsEqualAtPath: p1 andPath: p2]; ok = [self contentsEqualAtPath: p1 andPath: p2];
} }
RELEASE(pool); [pool drain];
} }
return ok; return ok;
} }
@ -1440,7 +1440,7 @@ static NSStringEncoding defaultEncoding;
item = [contents objectAtIndex: i]; item = [contents objectAtIndex: i];
next = [path stringByAppendingPathComponent: item]; next = [path stringByAppendingPathComponent: item];
result = [self removeFileAtPath: next handler: handler]; result = [self removeFileAtPath: next handler: handler];
[arp release]; [arp drain];
if (result == NO) if (result == NO)
{ {
return NO; return NO;
@ -2820,7 +2820,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
} }
[self changeFileAttributes: attributes atPath: destinationFile]; [self changeFileAttributes: attributes atPath: destinationFile];
} }
[pool release]; [pool drain];
return YES; return YES;
} }
@ -2910,7 +2910,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
} }
[self changeFileAttributes: attributes atPath: destinationFile]; [self changeFileAttributes: attributes atPath: destinationFile];
} }
[pool release]; [pool drain];
return YES; return YES;
#else #else
return NO; return NO;

View file

@ -478,7 +478,7 @@ static NSDictionary *makeReference(unsigned ref)
d = [self archivedDataWithRootObject: anObject]; d = [self archivedDataWithRootObject: anObject];
result = [d writeToFile: aPath atomically: YES]; result = [d writeToFile: aPath atomically: YES];
[pool release]; [pool drain];
return result; return result;
} }

View file

@ -357,6 +357,6 @@ NSLogv (NSString* format, va_list args)
[myLock unlock]; [myLock unlock];
[arp release]; [arp drain];
} }

View file

@ -1100,7 +1100,7 @@ static void clean_up_sockets(void)
unlink([name bytes]); unlink([name bytes]);
} }
NSEndMapTableEnumeration(&mEnum); NSEndMapTableEnumeration(&mEnum);
[arp release]; [arp drain];
if (unknownThread == YES) if (unknownThread == YES)
{ {
GSUnregisterCurrentThread(); GSUnregisterCurrentThread();

View file

@ -99,7 +99,7 @@ static void clean_up_names(void)
[defaultServer removePort: port]; [defaultServer removePort: port];
} }
NSEndMapTableEnumeration(&mEnum); NSEndMapTableEnumeration(&mEnum);
[arp release]; [arp drain];
if (unknownThread == YES) if (unknownThread == YES)
{ {
GSUnregisterCurrentThread(); GSUnregisterCurrentThread();

View file

@ -160,7 +160,7 @@ static Class NSPort_concrete_class;
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
postNotificationName: NSPortDidBecomeInvalidNotification postNotificationName: NSPortDidBecomeInvalidNotification
object: self]; object: self];
[arp release]; [arp drain];
} }
- (BOOL) isValid - (BOOL) isValid

View file

@ -449,7 +449,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
IF_NO_GC(RELEASE(keys)); IF_NO_GC(RELEASE(keys));
IF_NO_GC(RELEASE(values)); IF_NO_GC(RELEASE(values));
} }
IF_NO_GC(RELEASE(arp)); [arp drain];
} }
#if !GS_FAKE_MAIN && ((defined(HAVE_PROCFS) || defined(HAVE_KVM_ENV) || defined(HAVE_PROCFS_PSINFO) || defined(__APPLE__)) && (defined(HAVE_LOAD_METHOD))) #if !GS_FAKE_MAIN && ((defined(HAVE_PROCFS) || defined(HAVE_KVM_ENV) || defined(HAVE_PROCFS_PSINFO) || defined(__APPLE__)) && (defined(HAVE_LOAD_METHOD)))

View file

@ -486,7 +486,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
} }
} }
} }
[arp release]; [arp drain];
} }
/** /**
@ -757,7 +757,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
userInfo: nil userInfo: nil
repeats: YES]; repeats: YES];
context->housekeeper = timer; context->housekeeper = timer;
[arp release]; [arp drain];
} }
} }
return current; return current;
@ -1163,7 +1163,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
} }
GSPrivateNotifyASAP(_currentMode); GSPrivateNotifyASAP(_currentMode);
_currentMode = savedMode; _currentMode = savedMode;
[arp release]; [arp drain];
NS_VOIDRETURN; NS_VOIDRETURN;
} }
@ -1221,7 +1221,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
[localException raise]; [localException raise];
} }
NS_ENDHANDLER NS_ENDHANDLER
[arp release]; [arp drain];
} }
/** /**
@ -1247,7 +1247,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
d = [self limitDateForMode: mode]; d = [self limitDateForMode: mode];
if (d == nil) if (d == nil)
{ {
[arp release]; [arp drain];
return NO; return NO;
} }
@ -1266,7 +1266,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
[self acceptInputForMode: mode beforeDate: d]; [self acceptInputForMode: mode beforeDate: d];
[d release]; [d release];
[arp release]; [arp drain];
return YES; return YES;
} }

View file

@ -1182,7 +1182,7 @@ quotedFromString(NSString *aString)
[data appendBytes: &terminator length: 2]; // end of setting [data appendBytes: &terminator length: 2]; // end of setting
} }
[data appendBytes: &terminator length: 2]; // end of environment [data appendBytes: &terminator length: 2]; // end of environment
RELEASE(pool); [pool drain];
envp = [data mutableBytes]; envp = [data mutableBytes];
} }

View file

@ -1038,7 +1038,7 @@ static NSMapTable *absolutes = 0;
[md makeImmutableCopyOnFail: NO]; [md makeImmutableCopyOnFail: NO];
abbreviationDictionary = md; abbreviationDictionary = md;
} }
[pool release]; [pool drain];
} }
if (zone_mutex != nil) if (zone_mutex != nil)
{ {
@ -1184,7 +1184,7 @@ static NSMapTable *absolutes = 0;
[md makeImmutableCopyOnFail: NO]; [md makeImmutableCopyOnFail: NO];
abbreviationMap = RETAIN(md); abbreviationMap = RETAIN(md);
[pool release]; [pool drain];
} }
if (zone_mutex != nil) if (zone_mutex != nil)
{ {
@ -1840,7 +1840,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60);
} }
} }
regionsArray = [[NSArray alloc] initWithObjects: temp_array count: 24]; regionsArray = [[NSArray alloc] initWithObjects: temp_array count: 24];
[pool release]; [pool drain];
} }
if (zone_mutex != nil) if (zone_mutex != nil)
{ {

View file

@ -1539,7 +1539,7 @@ static BOOL isLocked = NO;
{ {
NSLog(@"Failed to lock user defaults database even after " NSLog(@"Failed to lock user defaults database even after "
@"breaking old locks!"); @"breaking old locks!");
[arp release]; [arp drain];
return NO; return NO;
} }
@ -1556,7 +1556,7 @@ static BOOL isLocked = NO;
{ {
[NSThread sleepUntilDate: when]; [NSThread sleepUntilDate: when];
} }
[arp release]; [arp drain];
} }
isLocked = YES; isLocked = YES;

View file

@ -1962,7 +1962,7 @@ static NSString *mainFont = nil;
node = tmp; node = tmp;
} }
} }
RELEASE(arp); [arp drain];
} }
/** /**

View file

@ -542,7 +542,7 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
{ {
CREATE_AUTORELEASE_POOL(pool); CREATE_AUTORELEASE_POOL(pool);
setDirectory(refs, path); setDirectory(refs, path);
RELEASE(pool); [pool drain];
} }
} }

View file

@ -1474,7 +1474,7 @@ static BOOL snuggleStart(NSString *t)
[buf appendString: @"\n"]; [buf appendString: @"\n"];
} }
} }
RELEASE(arp); [arp drain];
return ind; return ind;
} }

View file

@ -1744,7 +1744,7 @@ recheck:
{ {
if (buffer[pos] == ')' || buffer[pos] == ',') if (buffer[pos] == ')' || buffer[pos] == ',')
{ {
RELEASE(arp); [arp drain];
return d; return d;
} }
else else
@ -1877,7 +1877,7 @@ recheck:
} }
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
if (inArgList == NO) if (inArgList == NO)
{ {
/* /*
@ -1907,7 +1907,7 @@ recheck:
} }
fail: fail:
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
return nil; return nil;
} }
@ -2206,7 +2206,7 @@ fail:
*/ */
[self skipUnit]; [self skipUnit];
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
return [NSMutableDictionary dictionary]; return [NSMutableDictionary dictionary];
} }
else else
@ -2245,13 +2245,13 @@ fail:
unitName = nil; unitName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
return dict; return dict;
fail: fail:
unitName = nil; unitName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
return nil; return nil;
} }
@ -2401,13 +2401,13 @@ fail:
unitName = nil; unitName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
return dict; return dict;
fail: fail:
unitName = nil; unitName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
return nil; return nil;
} }
@ -2950,14 +2950,14 @@ fail:
} }
itemName = nil; itemName = nil;
RELEASE(arp); [arp drain];
IF_NO_GC([method autorelease];) IF_NO_GC([method autorelease];)
return method; return method;
fail: fail:
itemName = nil; itemName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
RELEASE(method); RELEASE(method);
return nil; return nil;
} }
@ -3661,14 +3661,14 @@ fail:
unitName = nil; unitName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
IF_NO_GC([dict autorelease];) IF_NO_GC([dict autorelease];)
return dict; return dict;
fail: fail:
unitName = nil; unitName = nil;
DESTROY(comment); DESTROY(comment);
RELEASE(arp); [arp drain];
RELEASE(dict); RELEASE(dict);
return nil; return nil;
} }
@ -4108,7 +4108,7 @@ fail:
buffer = [data mutableBytes]; buffer = [data mutableBytes];
pos = 0; pos = 0;
lines = [[NSArray alloc] initWithArray: a]; lines = [[NSArray alloc] initWithArray: a];
RELEASE(arp); [arp drain];
IF_NO_GC([lines autorelease];) IF_NO_GC([lines autorelease];)
IF_NO_GC([data autorelease];) IF_NO_GC([data autorelease];)
} }

View file

@ -1351,7 +1351,7 @@ int main (int argc, char** argv, char** env)
} }
RELEASE (linker); RELEASE (linker);
RELEASE (pool); [pool drain];
return 0; return 0;
} }

View file

@ -64,7 +64,7 @@ main(int argc, char** argv, char **env)
if (proc == nil) if (proc == nil)
{ {
GSPrintf(stderr, @"gspath: unable to get process information!\n"); GSPrintf(stderr, @"gspath: unable to get process information!\n");
[pool release]; [pool drain];
return 1; return 1;
} }
@ -116,7 +116,7 @@ main(int argc, char** argv, char **env)
} }
if (ok == YES) if (ok == YES)
{ {
[pool release]; [pool drain];
return 0; return 0;
} }
} }
@ -141,6 +141,6 @@ main(int argc, char** argv, char **env)
@"user\n" @"user\n"
@" The GNUstep home directory of the current user\n\n" @" The GNUstep home directory of the current user\n\n"
); );
[pool release]; [pool drain];
return 1; return 1;
} }

View file

@ -166,7 +166,7 @@ int main (int argc, const char *argv[])
puts(" if -output is specified."); puts(" if -output is specified.");
} }
[pool release]; [pool drain];
exit(0); // insure the process exit status is 0 exit(0); // insure the process exit status is 0
return 0; // ...and make main fit the ANSI spec. return 0; // ...and make main fit the ANSI spec.
} }