From aa5229a6cbbfd89afc85eb115a5f5bdaba227402 Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 28 Feb 2011 19:49:57 +0000 Subject: [PATCH] avoid compiler warnings git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32417 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 34 +++++++++++++ Source/Additions/GSMime.m | 50 +++++++++---------- Source/Additions/GSObjCRuntime.m | 14 +++--- Source/Additions/GSXML.m | 2 +- Source/Additions/NSCalendarDate+GNUstepBase.m | 4 +- Source/Additions/NSData+GNUstepBase.m | 18 +++---- Source/GSArray.m | 6 +-- Source/GSSet.m | 8 +-- Source/GSeq.h | 7 ++- Source/NSBundle.m | 11 ++-- Source/NSConnection.m | 24 ++++----- Source/NSDebug.m | 6 +-- Source/NSDistributedNotificationCenter.m | 7 +-- Source/NSException.m | 15 +++--- Source/NSFileManager.m | 14 +++--- Source/NSKeyedArchiver.m | 13 ++--- Source/NSLog.m | 10 ++-- Source/NSMessagePort.m | 12 ++--- Source/NSMessagePortNameServer.m | 4 +- Source/NSOperation.m | 6 +-- Source/NSPort.m | 4 +- Source/NSPortCoder.m | 16 +++--- Source/NSProcessInfo.m | 2 +- Source/NSPropertyList.m | 4 +- Source/NSRunLoop.m | 37 +++++++------- Source/NSString.m | 3 +- Source/NSTask.m | 2 +- Source/NSThread.m | 2 +- Source/NSTimeZone.m | 17 ++++--- Source/NSUserDefaults.m | 10 ++-- Source/win32/NSMessagePortNameServer.m | 2 +- 31 files changed, 201 insertions(+), 163 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7dfb815b..5903fe2bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2011-02-28 Richard Frith-Macdonald + + * Source/NSTimeZone.m: + * Source/NSPortCoder.m: + * Source/NSBundle.m: + * Source/NSPropertyList.m: + * Source/NSDistributedNotificationCenter.m: + * Source/NSProcessInfo.m: + * Source/NSRunLoop.m: + * Source/NSOperation.m: + * Source/NSUserDefaults.m: + * Source/GSArray.m: + * Source/NSMessagePortNameServer.m: + * Source/NSKeyedArchiver.m: + * Source/NSDebug.m: + * Source/NSPort.m: + * Source/NSMessagePort.m: + * Source/win32/NSMessagePortNameServer.m: + * Source/NSFileManager.m: + * Source/NSException.m: + * Source/NSString.m: + * Source/Additions/NSData+GNUstepBase.m: + * Source/Additions/GSMime.m: + * Source/Additions/NSCalendarDate+GNUstepBase.m: + * Source/Additions/GSXML.m: + * Source/Additions/GSObjCRuntime.m: + * Source/GSSet.m: + * Source/NSConnection.m: + * Source/NSThread.m: + * Source/GSeq.h: + * Source/NSLog.m: + * Source/NSTask.m: + Tweaks to avoid compiler warnings in garbage collecting environment. + 2011-02-27 Richard Frith-Macdonald * Tests/GNUmakefile: Use gnustep-make to supply targets. diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 12c7c16fe..337f712d7 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -5418,17 +5418,17 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold, { NSMutableArray *partData = nil; NSMutableData *md = [NSMutableData dataWithCapacity: 1024]; - NSData *d = nil; - NSEnumerator *enumerator; - GSMimeHeader *type; - GSMimeHeader *enc; - GSMimeHeader *hdr; - NSData *boundary = 0; - BOOL contentIsBinary = NO; - BOOL contentIs7bit = YES; - NSUInteger count; - NSUInteger i; - CREATE_AUTORELEASE_POOL(arp); + NSData *d = nil; + NSEnumerator *enumerator; + GSMimeHeader *type; + GSMimeHeader *enc; + GSMimeHeader *hdr; + NSData *boundary = 0; + BOOL contentIsBinary = NO; + BOOL contentIs7bit = YES; + NSUInteger count; + NSUInteger i; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; if (isOuter == YES) { @@ -5865,7 +5865,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold, [md appendData: d]; } } - RELEASE(arp); + [arp release]; return md; } @@ -5960,9 +5960,9 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold, type: (NSString*)type name: (NSString*)name { - NSString *subtype = nil; - GSMimeHeader *hdr = nil; - CREATE_AUTORELEASE_POOL(arp); + NSString *subtype = nil; + GSMimeHeader *hdr = nil; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; if (type == nil) { @@ -6028,7 +6028,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold, [self setContent: newContent]; [self setHeader: hdr]; - RELEASE(arp); + [arp release]; } /** @@ -6040,10 +6040,10 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold, */ - (void) setContentType: (NSString *)newType { - GSMimeHeader *hdr = nil; - GSMimeParser *p; - NSScanner *scanner; - CREATE_AUTORELEASE_POOL(arp); + GSMimeHeader *hdr = nil; + GSMimeParser *p; + NSScanner *scanner; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; p = AUTORELEASE([GSMimeParser new]); scanner = [NSScanner scannerWithString: newType]; @@ -6055,7 +6055,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold, format: @"Unable to parse type information"]; } [self setHeader: hdr]; - RELEASE(arp); + [arp release]; } /** @@ -6704,7 +6704,7 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient) { NS_DURING { - RETAIN(self); // Make sure we don't get released until done. + [self retain]; // Make sure we don't get released until done. /* First perform all reads ... so we process incoming data, */ @@ -6830,7 +6830,7 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient) } } - RELEASE(self); + [self release]; } NS_HANDLER { @@ -7206,8 +7206,8 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient) port: pnum inputStream: &internal->istream outputStream: &internal->ostream]; - RETAIN(internal->istream); - RETAIN(internal->ostream); + [internal->istream retain]; + [internal->ostream retain]; if (internal->istream == nil || internal->ostream == nil) { NSLog(@"Unable to connect to %@:%@", n, p); diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index aeeee4297..e7a361994 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -1956,11 +1956,11 @@ GSPrintf (FILE *fptr, NSString* format, ...) { static Class stringClass = 0; static NSStringEncoding enc; - va_list ap; - NSString *message; - NSData *data; - BOOL ok = NO; - CREATE_AUTORELEASE_POOL(arp); + va_list ap; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *message; + NSData *data; + BOOL ok = NO; if (stringClass == 0) { @@ -1976,7 +1976,7 @@ GSPrintf (FILE *fptr, NSString* format, ...) { data = [message dataUsingEncoding: NSUTF8StringEncoding]; } - RELEASE(message); + [message release]; if (data != nil) { @@ -1987,7 +1987,7 @@ GSPrintf (FILE *fptr, NSString* format, ...) ok = YES; } } - RELEASE(arp); + [arp release]; return ok; } diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index f44602320..507f70ed9 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -1746,7 +1746,7 @@ static NSString *endMarker = @"At end of incremental parse"; * Creation of a new Parser by calling * -initWithSAXHandler:withContentsOfFile: * - * CREATE_AUTORELEASE_POOL(arp); + * NSAutoreleasePool *arp = [NSAutoreleasePool new]; * GSSAXHandler *h = [GSDebugSAXHandler handler]; * GSXMLParser *p = [GSXMLParser parserWithSAXHandler: h * withContentsOfFile: @"macos.xml"]; diff --git a/Source/Additions/NSCalendarDate+GNUstepBase.m b/Source/Additions/NSCalendarDate+GNUstepBase.m index 9e4d340a5..2efc14639 100644 --- a/Source/Additions/NSCalendarDate+GNUstepBase.m +++ b/Source/Additions/NSCalendarDate+GNUstepBase.m @@ -54,7 +54,7 @@ */ if (dayOfWeek != 4) { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSCalendarDate *thursday; /* @@ -72,7 +72,7 @@ minutes: 0 seconds: 0]; dayOfYear = [thursday dayOfYear]; - RELEASE(arp); + [arp release]; } else { diff --git a/Source/Additions/NSData+GNUstepBase.m b/Source/Additions/NSData+GNUstepBase.m index 5c4b24bcf..c1679eac3 100644 --- a/Source/Additions/NSData+GNUstepBase.m +++ b/Source/Additions/NSData+GNUstepBase.m @@ -90,14 +90,14 @@ */ - (id) initWithHexadecimalRepresentation: (NSString*)string { - CREATE_AUTORELEASE_POOL(arp); - NSData *d; - const char *src; - const char *end; - unsigned char *dst; - unsigned int pos = 0; - unsigned char byte = 0; - BOOL high = NO; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSData *d; + const char *src; + const char *end; + unsigned char *dst; + unsigned int pos = 0; + unsigned char byte = 0; + BOOL high = NO; d = [string dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: YES]; @@ -152,7 +152,7 @@ DESTROY(self); } NSZoneFree(NSDefaultMallocZone(), dst); - RELEASE(arp); + [arp release]; if (self == nil) { [NSException raise: NSInvalidArgumentException diff --git a/Source/GSArray.m b/Source/GSArray.m index 044e4863d..376807140 100644 --- a/Source/GSArray.m +++ b/Source/GSArray.m @@ -723,7 +723,7 @@ static Class GSInlineArrayClass; index++; } _contents_array[_count] = 0; - RELEASE(obj); /* Adjust array BEFORE releasing object. */ + [obj release]; /* Adjust array BEFORE releasing object. */ _version++; } @@ -788,9 +788,9 @@ static Class GSInlineArrayClass; * array in case a retain or release causes an exception. */ obj = _contents_array[index]; - IF_NO_GC(RETAIN(anObject)); + [anObject retain]; _contents_array[index] = anObject; - RELEASE(obj); + [obj release]; _version++; } diff --git a/Source/GSSet.m b/Source/GSSet.m index 8af53126b..d528cad9a 100644 --- a/Source/GSSet.m +++ b/Source/GSSet.m @@ -116,10 +116,6 @@ static Class mutableSetClass; { if (self == [GSSet class]) { - arrayClass = [NSArray class]; - setClass = [GSSet class]; - mutableSetClass = [GSMutableSet class]; - memberSel = @selector(member:); #if GS_WITH_GC /* We create a typed memory descriptor for map nodes. * Only the pointer to the key needs to be scanned. @@ -128,6 +124,10 @@ static Class mutableSetClass; GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key)); nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t)); #endif + arrayClass = [NSArray class]; + setClass = [GSSet class]; + mutableSetClass = [GSMutableSet class]; + memberSel = @selector(member:); } } diff --git a/Source/GSeq.h b/Source/GSeq.h index 969a313ff..fdff7e7f1 100644 --- a/Source/GSeq.h +++ b/Source/GSeq.h @@ -598,7 +598,6 @@ GSEQ_STRRANGE(NSString *ss, NSString *os, unsigned mask, NSRange aRange) { GSEQ_ST s = (GSEQ_ST)ss; GSEQ_OT o = (GSEQ_OT)os; - unsigned myLength; unsigned myIndex; unsigned myEndIndex; unsigned strLength; @@ -617,10 +616,10 @@ GSEQ_STRRANGE(NSString *ss, NSString *os, unsigned mask, NSRange aRange) NSRange (*orImp)(NSString*, SEL, unsigned); #endif - /* Check that the search range is reasonable */ - myLength = GSEQ_SLEN; - #if 0 + /* Check that the search range is reasonable */ + unsigned myLength = GSEQ_SLEN; + /* Range should be checked in calling code */ if (aRange.location > myLength) [NSException raise: NSRangeException format: @"Invalid location."]; diff --git a/Source/NSBundle.m b/Source/NSBundle.m index a3ce4dff5..be4ee30ef 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -1904,9 +1904,9 @@ IF_NO_GC( inDirectory: (NSString*)subPath forLocalization: (NSString*)localizationName { - CREATE_AUTORELEASE_POOL(arp); - NSString *result = nil; - NSArray *array; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *result = nil; + NSArray *array; if ([ext length] == 0) { @@ -1937,8 +1937,9 @@ IF_NO_GC( } } } - IF_NO_GC([result retain]; DESTROY(arp);) - return AUTORELEASE(result); + [result retain]; + [arp release]; + return [result autorelease]; } + (NSArray *) preferredLocalizationsFromArray: (NSArray *)localizationsArray diff --git a/Source/NSConnection.m b/Source/NSConnection.m index 2b59c9afb..e8e175cac 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -634,8 +634,6 @@ static NSLock *cached_proxies_gate = nil; { NSNotificationCenter *nc; - GSMakeWeakPointer(self, "delegate"); - #if GS_WITH_GC /* We create a typed memory descriptor for map nodes. * FIXME @@ -645,6 +643,8 @@ static NSLock *cached_proxies_gate = nil; GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value)); nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t)); #endif + + GSMakeWeakPointer(self, "delegate"); connectionClass = self; dateClass = [NSDate class]; distantObjectClass = [NSDistantObject class]; @@ -708,17 +708,17 @@ static NSLock *cached_proxies_gate = nil; + (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)n host: (NSString*)h { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSConnection *connection; NSDistantObject *proxy = nil; connection = [self connectionWithRegisteredName: n host: h]; if (connection != nil) { - proxy = RETAIN([connection rootProxy]); + proxy = [[connection rootProxy] retain]; } - RELEASE(arp); - return AUTORELEASE(proxy); + [arp release]; + return [proxy autorelease]; } /** @@ -734,7 +734,7 @@ static NSLock *cached_proxies_gate = nil; + (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)n host: (NSString*)h usingNameServer: (NSPortNameServer*)s { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSConnection *connection; NSDistantObject *proxy = nil; @@ -745,7 +745,7 @@ static NSLock *cached_proxies_gate = nil; { proxy = RETAIN([connection rootProxy]); } - RELEASE(arp); + [arp release]; return AUTORELEASE(proxy); } @@ -1305,12 +1305,12 @@ static NSLock *cached_proxies_gate = nil; * is done before the deallocation completes. */ { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; [[NSNotificationCenter defaultCenter] postNotificationName: NSConnectionDidDieNotification object: self]; - RELEASE(arp); + [arp release]; } /* @@ -1885,7 +1885,7 @@ static NSLock *cached_proxies_gate = nil; - (void) finalize { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; if (debug_connection) NSLog(@"finalising %@", self); @@ -1950,7 +1950,7 @@ static NSLock *cached_proxies_gate = nil; DESTROY(IrefGate); - RELEASE(arp); + [arp release]; } /* diff --git a/Source/NSDebug.m b/Source/NSDebug.m index df377dd16..b276d7f55 100644 --- a/Source/NSDebug.m +++ b/Source/NSDebug.m @@ -683,7 +683,7 @@ _GSDebugAllocationRemove(Class c, id o) } } [uniqueLock unlock]; - RELEASE(tag); + [tag release]; return; } } @@ -1088,7 +1088,7 @@ NSMutableArray * GSPrivateStackAddresses(void) { NSMutableArray *stack; - NSAutoreleasePool *pool; + NSAutoreleasePool *pool; #if HAVE_BACKTRACE void *addresses[1024]; @@ -1182,7 +1182,7 @@ GSPrivateStackAddresses(void) signal(SIGBUS, env->bus); } #endif - RELEASE(pool); + [pool release]; return stack; } diff --git a/Source/NSDistributedNotificationCenter.m b/Source/NSDistributedNotificationCenter.m index 2ab116438..1b34e1099 100644 --- a/Source/NSDistributedNotificationCenter.m +++ b/Source/NSDistributedNotificationCenter.m @@ -736,13 +736,14 @@ static NSDistributedNotificationCenter *netCenter = nil; limit = [NSDate dateWithTimeIntervalSinceNow: 5.0]; while (_remote == nil && [limit timeIntervalSinceNow] > 0) { - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + [NSThread sleepForTimeInterval: 0.05]; _remote = [NSConnection rootProxyForConnectionWithRegisteredName: service host: host usingNameServer: ns]; - IF_NO_GC([_remote retain];) - IF_NO_GC(DESTROY(pool);) + [_remote retain]; + [pool release]; } if (_remote == nil) { diff --git a/Source/NSException.m b/Source/NSException.m index c2b29b155..deabec63b 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -759,7 +759,8 @@ static void _terminate() static void _NSFoundationUncaughtExceptionHandler (NSException *exception) { - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + fprintf(stderr, "%s: Uncaught exception %s, reason: %s\n", GSPrivateArgZero(), [[exception name] lossyCString], [[exception reason] lossyCString]); @@ -770,7 +771,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception) [[[exception _callStack] description] lossyCString]); } fflush(stderr); /* NEEDED UNDER MINGW */ - RELEASE(pool); + [pool release]; _terminate(); } @@ -907,8 +908,8 @@ callUncaughtHandler(id value) - (NSString*) description { - CREATE_AUTORELEASE_POOL(pool); - NSString *result; + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSString *result; if (_e_name == nil) { @@ -945,9 +946,9 @@ callUncaughtHandler(id value) result = [NSString stringWithFormat: @"%@ NAME:%@ REASON:%@", [super description], _e_name, _e_reason]; } - IF_NO_GC([result retain];) - IF_NO_GC(DESTROY(pool);) - return AUTORELEASE(result); + [result retain]; + [pool release]; + return [result autorelease]; } - (void) raise diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index f7f2ae1e0..af7a27424 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -666,7 +666,7 @@ static NSStringEncoding defaultEncoding; NSString *n = [a1 objectAtIndex: index]; NSString *p1; NSString *p2; - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; p1 = [path1 stringByAppendingPathComponent: n]; p2 = [path2 stringByAppendingPathComponent: n]; @@ -1404,12 +1404,12 @@ static NSStringEncoding defaultEncoding; NSString *item; NSString *next; BOOL result; - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; item = [contents objectAtIndex: i]; next = [path stringByAppendingPathComponent: item]; result = [self removeFileAtPath: next handler: handler]; - RELEASE(arp); + [arp release]; if (result == NO) { return NO; @@ -2700,7 +2700,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X) { NSDirectoryEnumerator *enumerator; NSString *dirEntry; - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; enumerator = [self enumeratorAtPath: source]; while ((dirEntry = [enumerator nextObject])) @@ -2789,7 +2789,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X) } [self changeFileAttributes: attributes atPath: destinationFile]; } - RELEASE(pool); + [pool release]; return YES; } @@ -2801,7 +2801,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X) #ifdef HAVE_LINK NSDirectoryEnumerator *enumerator; NSString *dirEntry; - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; enumerator = [self enumeratorAtPath: source]; while ((dirEntry = [enumerator nextObject])) @@ -2879,7 +2879,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X) } [self changeFileAttributes: attributes atPath: destinationFile]; } - RELEASE(pool); + [pool release]; return YES; #else return NO; diff --git a/Source/NSKeyedArchiver.m b/Source/NSKeyedArchiver.m index 480527130..6510de261 100644 --- a/Source/NSKeyedArchiver.m +++ b/Source/NSKeyedArchiver.m @@ -468,13 +468,13 @@ static NSDictionary *makeReference(unsigned ref) + (BOOL) archiveRootObject: (id)anObject toFile: (NSString*)aPath { - CREATE_AUTORELEASE_POOL(pool); - NSData *d; - BOOL result; + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSData *d; + BOOL result; d = [self archivedDataWithRootObject: anObject]; result = [d writeToFile: aPath atomically: YES]; - RELEASE(pool); + [pool release]; return result; } @@ -485,8 +485,6 @@ static NSDictionary *makeReference(unsigned ref) + (void) initialize { - GSMakeWeakPointer(self, "delegate"); - #if GS_WITH_GC /* We create a typed memory descriptor for map nodes. */ @@ -495,6 +493,9 @@ static NSDictionary *makeReference(unsigned ref) GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value)); nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t)); #endif + + GSMakeWeakPointer(self, "delegate"); + if (globalClassMap == 0) { globalClassMap = diff --git a/Source/NSLog.m b/Source/NSLog.m index d57e790e8..ef4fdc15d 100644 --- a/Source/NSLog.m +++ b/Source/NSLog.m @@ -282,10 +282,10 @@ NSLog (NSString* format, ...) void NSLogv (NSString* format, va_list args) { - NSString *prefix; - NSString *message; - static int pid = 0; - CREATE_AUTORELEASE_POOL(arp); + NSString *prefix; + NSString *message; + static int pid = 0; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; if (_NSLog_printf_handler == NULL) { @@ -357,6 +357,6 @@ NSLogv (NSString* format, va_list args) [myLock unlock]; - RELEASE(arp); + [arp release]; } diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index dc33d7d8b..dbed3d6ca 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -1087,11 +1087,11 @@ static Class messagePortClass; static void clean_up_sockets(void) { - NSMessagePort *port; - NSData *name; - NSMapEnumerator mEnum; - BOOL unknownThread = GSRegisterCurrentThread(); - CREATE_AUTORELEASE_POOL(arp); + NSMessagePort *port; + NSData *name; + NSMapEnumerator mEnum; + BOOL unknownThread = GSRegisterCurrentThread(); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; mEnum = NSEnumerateMapTable(messagePortMap); while (NSNextMapEnumeratorPair(&mEnum, (void *)&name, (void *)&port)) @@ -1100,7 +1100,7 @@ static void clean_up_sockets(void) unlink([name bytes]); } NSEndMapTableEnumeration(&mEnum); - IF_NO_GC(DESTROY(arp);) + [arp release]; if (unknownThread == YES) { GSUnregisterCurrentThread(); diff --git a/Source/NSMessagePortNameServer.m b/Source/NSMessagePortNameServer.m index fc2fbac90..c96f36b97 100644 --- a/Source/NSMessagePortNameServer.m +++ b/Source/NSMessagePortNameServer.m @@ -91,7 +91,7 @@ static void clean_up_names(void) NSMessagePort *port; NSString *name; BOOL unknownThread = GSRegisterCurrentThread(); - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; mEnum = NSEnumerateMapTable(portToNamesMap); while (NSNextMapEnumeratorPair(&mEnum, (void *)&port, (void *)&name)) @@ -99,7 +99,7 @@ static void clean_up_names(void) [defaultServer removePort: port]; } NSEndMapTableEnumeration(&mEnum); - IF_NO_GC(DESTROY(arp);) + [arp release]; if (unknownThread == YES) { GSUnregisterCurrentThread(); diff --git a/Source/NSOperation.m b/Source/NSOperation.m index e9f463e49..a70118ed9 100644 --- a/Source/NSOperation.m +++ b/Source/NSOperation.m @@ -373,8 +373,8 @@ static NSArray *empty = nil; - (void) start { - CREATE_AUTORELEASE_POOL(pool); - double prio = [NSThread threadPriority]; + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + double prio = [NSThread threadPriority]; [internal->lock lock]; NS_DURING @@ -452,7 +452,7 @@ static NSArray *empty = nil; } NS_ENDHANDLER [internal->lock unlock]; - RELEASE(pool); + [pool release]; } - (double) threadPriority diff --git a/Source/NSPort.m b/Source/NSPort.m index 4218a9c0c..21946d3a0 100644 --- a/Source/NSPort.m +++ b/Source/NSPort.m @@ -154,13 +154,13 @@ static Class NSPort_concrete_class; */ - (void) invalidate { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; _is_valid = NO; [[NSNotificationCenter defaultCenter] postNotificationName: NSPortDidBecomeInvalidNotification object: self]; - RELEASE(arp); + [arp release]; } - (BOOL) isValid diff --git a/Source/NSPortCoder.m b/Source/NSPortCoder.m index 07b9d63a2..d96012b6a 100644 --- a/Source/NSPortCoder.m +++ b/Source/NSPortCoder.m @@ -350,6 +350,14 @@ static IMP _xRefImp; /* Serialize a crossref. */ { if (self == [NSPortCoder class]) { +#if GS_WITH_GC + /* We create a typed memory descriptor for map nodes. + */ + GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0}; + GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key)); + GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value)); + nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t)); +#endif connectionClass = [NSConnection class]; mutableArrayClass = [NSMutableArray class]; mutableDataClass = [NSMutableDataMalloc class]; @@ -365,14 +373,6 @@ static IMP _xRefImp; /* Serialize a crossref. */ _eTagImp = [mutableDataClass instanceMethodForSelector: eTagSel]; _xRefImp = [mutableDataClass instanceMethodForSelector: xRefSel]; mutableDictionaryClass = [NSMutableDictionary class]; -#if GS_WITH_GC - /* We create a typed memory descriptor for map nodes. - */ - GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0}; - GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key)); - GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value)); - nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t)); -#endif } } diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index f39b4a34b..271fc380f 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -225,7 +225,7 @@ static NSMutableSet *mySet = nil; static void _gnu_process_args(int argc, char *argv[], char *env[]) { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSString *arg0 = nil; int i; diff --git a/Source/NSPropertyList.m b/Source/NSPropertyList.m index 2b7fe685d..b0600bccc 100644 --- a/Source/NSPropertyList.m +++ b/Source/NSPropertyList.m @@ -175,7 +175,7 @@ foundIgnorableWhitespace: (NSString *)string if (key == nil) { - key = RETAIN([NSNull null]); + key = [[NSNull null] retain]; } [stack addObject: key]; DESTROY(key); @@ -191,7 +191,7 @@ foundIgnorableWhitespace: (NSString *)string if (key == nil) { - key = RETAIN([NSNull null]); + key = [[NSNull null] retain]; } [stack addObject: key]; DESTROY(key); diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 7b7187f36..117b28691 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -423,7 +423,8 @@ static inline BOOL timerInvalidated(NSTimer *t) - (void) _checkPerformers: (GSRunLoopCtxt*)context { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + if (context != nil) { GSIArray performers = context->performers; @@ -481,11 +482,11 @@ static inline BOOL timerInvalidated(NSTimer *t) { [array[i] fire]; RELEASE(array[i]); - IF_NO_GC([arp emptyPool]); + IF_NO_GC([arp emptyPool];) } } } - RELEASE(arp); + [arp release]; } /** @@ -715,7 +716,7 @@ static inline BOOL timerInvalidated(NSTimer *t) */ if ([GSCurrentThread() isMainThread] == YES) { - CREATE_AUTORELEASE_POOL (arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; GSRunLoopCtxt *context; NSNotificationCenter *ctr; NSNotification *not; @@ -756,7 +757,7 @@ static inline BOOL timerInvalidated(NSTimer *t) userInfo: nil repeats: YES]; context->housekeeper = timer; - RELEASE(arp); + [arp release]; } } return current; @@ -942,7 +943,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) if (context != nil) { NSString *savedMode = _currentMode; - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; _currentMode = mode; NS_DURING @@ -982,7 +983,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) { [t fire]; GSPrivateNotifyASAP(_currentMode); - IF_NO_GC([arp emptyPool]); + IF_NO_GC([arp emptyPool];) updateTimer(t, d, now); } } @@ -1007,7 +1008,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) GSIArrayRemoveItemAtIndexNoRelease(timers, i); [t fire]; GSPrivateNotifyASAP(_currentMode); - IF_NO_GC([arp emptyPool]); + IF_NO_GC([arp emptyPool];) if (updateTimer(t, d, now) == YES) { /* Updated ... replace in array. @@ -1069,7 +1070,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) } NS_ENDHANDLER - RELEASE(arp); + [arp release]; if (when == nil) { @@ -1119,7 +1120,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) NSTimeInterval ti = 0; int timeout_ms; NSString *savedMode = _currentMode; - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSAssert(mode, NSInvalidArgumentException); if (mode == nil) @@ -1163,7 +1164,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) } GSPrivateNotifyASAP(_currentMode); _currentMode = savedMode; - RELEASE(arp); + [arp release]; NS_VOIDRETURN; } @@ -1221,7 +1222,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) [localException raise]; } NS_ENDHANDLER - RELEASE(arp); + [arp release]; } /** @@ -1238,8 +1239,8 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) */ - (BOOL) runMode: (NSString*)mode beforeDate: (NSDate*)date { - CREATE_AUTORELEASE_POOL(arp); - NSDate *d; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSDate *d; NSAssert(mode != nil, NSInvalidArgumentException); @@ -1247,7 +1248,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) d = [self limitDateForMode: mode]; if (d == nil) { - RELEASE(arp); + [arp release]; return NO; } @@ -1260,13 +1261,13 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) { d = [d earlierDate: date]; } - IF_NO_GC(RETAIN(d)); + [d retain]; /* Wait, listening to our input sources. */ [self acceptInputForMode: mode beforeDate: d]; - RELEASE(d); - RELEASE(arp); + [d release]; + [arp release]; return YES; } diff --git a/Source/NSString.m b/Source/NSString.m index 80d3f20c4..cffaf06ae 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -2270,7 +2270,7 @@ handle_printf_atsign (FILE *stream, int prefix_len = 0; unsigned length = [self length]; unsigned aLength = [aString length]; - unichar *u,*w; + unichar *u; unichar a1[length+1]; unichar *s1 = a1; unichar a2[aLength+1]; @@ -2281,7 +2281,6 @@ handle_printf_atsign (FILE *stream, [aString getCharacters: s2 range: ((NSRange){0, aLength})]; s2[aLength] = (unichar)0; u = s1; - w = s2; if (mask & NSCaseInsensitiveSearch) { diff --git a/Source/NSTask.m b/Source/NSTask.m index 77a85b232..a09cff767 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -1150,7 +1150,7 @@ quotedFromString(NSString *aString) NSEnumerator *enumerator; NSString *key; unichar terminator = 0; - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; // Win32 environment variables must be sorted by name enumerator = [[[env allKeys] diff --git a/Source/NSThread.m b/Source/NSThread.m index 3a5d5c630..d7fb06f71 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -829,7 +829,7 @@ static void *nsthreadLauncher(void* thread) /* The thread must persist until it finishes executing. */ - RETAIN(self); + [self retain]; /* Mark the thread as active whiul it's running. */ diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index 37a8bf5ac..bfc91acfb 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -993,7 +993,7 @@ static NSMapTable *absolutes = 0; } if (abbreviationDictionary == nil) { - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSString *path; path = _time_zone_path (ABBREV_DICT, @"plist"); @@ -1038,7 +1038,7 @@ static NSMapTable *absolutes = 0; [md makeImmutableCopyOnFail: NO]; abbreviationDictionary = md; } - RELEASE(pool); + [pool release]; } if (zone_mutex != nil) { @@ -1067,7 +1067,7 @@ static NSMapTable *absolutes = 0; } if (abbreviationMap == nil) { - CREATE_AUTORELEASE_POOL(pool); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSMutableDictionary *md; NSMutableArray *ma; NSString *the_name; @@ -1184,7 +1184,7 @@ static NSMapTable *absolutes = 0; [md makeImmutableCopyOnFail: NO]; abbreviationMap = RETAIN(md); - RELEASE(pool); + [pool release]; } if (zone_mutex != nil) { @@ -1717,9 +1717,10 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); } if (regionsArray == nil) { - CREATE_AUTORELEASE_POOL(pool); - int index, i; - char name[80]; + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + int index; + int i; + char name[80]; FILE *fp; NSMutableArray *temp_array[24]; NSString *path; @@ -1839,7 +1840,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); } } regionsArray = [[NSArray alloc] initWithObjects: temp_array count: 24]; - RELEASE(pool); + [pool release]; } if (zone_mutex != nil) { diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 9c60a25ae..affac20bb 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -1559,9 +1559,9 @@ static BOOL isLocked = NO; while ([_fileLock tryLock] == NO) { - CREATE_AUTORELEASE_POOL(arp); - NSDate *when; - NSDate *lockDate; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSDate *when; + NSDate *lockDate; lockDate = [_fileLock lockDate]; when = [NSDateClass dateWithTimeIntervalSinceNow: 0.1]; @@ -1576,7 +1576,7 @@ static BOOL isLocked = NO; { NSLog(@"Failed to lock user defaults database even after " @"breaking old locks!"); - RELEASE(arp); + [arp release]; return NO; } @@ -1593,7 +1593,7 @@ static BOOL isLocked = NO; { [NSThread sleepUntilDate: when]; } - RELEASE(arp); + [arp release]; } isLocked = YES; diff --git a/Source/win32/NSMessagePortNameServer.m b/Source/win32/NSMessagePortNameServer.m index 3ed6d29df..3994852fe 100644 --- a/Source/win32/NSMessagePortNameServer.m +++ b/Source/win32/NSMessagePortNameServer.m @@ -70,7 +70,7 @@ static void clean_up_names(void) NSMessagePort *port; NSString *name; BOOL unknownThread = GSRegisterCurrentThread(); - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; mEnum = NSEnumerateMapTable(portToNamesMap); while (NSNextMapEnumeratorPair(&mEnum, (void *)&port, (void *)&name))