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:
David Chisnall 2011-05-27 11:48:44 +00:00
parent 29063b6928
commit 7764740bdc
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];
}
}
[arp release];
[arp drain];
return md;
}
@ -6195,7 +6195,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
[self setContent: newContent];
[self setHeader: hdr];
[arp release];
[arp drain];
}
/**
@ -6222,7 +6222,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
format: @"Unable to parse type information"];
}
[self setHeader: hdr];
[arp release];
[arp drain];
}
/**

View file

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

View file

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

View file

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

View file

@ -465,7 +465,9 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
- (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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -160,7 +160,7 @@ static Class NSPort_concrete_class;
[[NSNotificationCenter defaultCenter]
postNotificationName: NSPortDidBecomeInvalidNotification
object: self];
[arp release];
[arp drain];
}
- (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(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)))

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
repeats: YES];
context->housekeeper = timer;
[arp release];
[arp drain];
}
}
return current;
@ -1163,7 +1163,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
}
GSPrivateNotifyASAP(_currentMode);
_currentMode = savedMode;
[arp release];
[arp drain];
NS_VOIDRETURN;
}
@ -1221,7 +1221,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
[localException raise];
}
NS_ENDHANDLER
[arp release];
[arp drain];
}
/**
@ -1247,7 +1247,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
d = [self limitDateForMode: mode];
if (d == nil)
{
[arp release];
[arp drain];
return NO;
}
@ -1266,7 +1266,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
[self acceptInputForMode: mode beforeDate: d];
[d release];
[arp release];
[arp drain];
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 environment
RELEASE(pool);
[pool drain];
envp = [data mutableBytes];
}

View file

@ -1038,7 +1038,7 @@ static NSMapTable *absolutes = 0;
[md makeImmutableCopyOnFail: NO];
abbreviationDictionary = md;
}
[pool release];
[pool drain];
}
if (zone_mutex != nil)
{
@ -1184,7 +1184,7 @@ static NSMapTable *absolutes = 0;
[md makeImmutableCopyOnFail: NO];
abbreviationMap = RETAIN(md);
[pool release];
[pool drain];
}
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];
[pool release];
[pool drain];
}
if (zone_mutex != nil)
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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