@@ -26,13 +26,14 @@ #import "OFApplication.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" -#import "OFAutoreleasePool.h" #import "OFNotImplementedException.h" + +#import "autorelease.h" #if defined(__MACH__) && !defined(OF_IOS) # include #elif !defined(OF_IOS) extern char **environ; @@ -118,11 +119,11 @@ - init { self = [super init]; @try { - OFAutoreleasePool *pool; + void *pool; #if defined(__MACH__) && !defined(OF_IOS) char **env = *_NSGetEnviron(); #elif !defined(OF_IOS) char **env = environ; #else @@ -130,17 +131,17 @@ #endif environment = [[OFMutableDictionary alloc] init]; atexit(atexit_handler); - - pool = [[OFAutoreleasePool alloc] init]; #ifndef OF_IOS for (; *env != NULL; env++) { OFString *key; OFString *value; char *sep; + + pool = objc_autoreleasePoolPush(); if ((sep = strchr(*env, '=')) == NULL) { fprintf(stderr, "Warning: Invalid environment " "variable: %s\n", *env); continue; @@ -154,19 +155,21 @@ stringWithCString: sep + 1 encoding: OF_STRING_ENCODING_NATIVE]; [environment setObject: value forKey: key]; - [pool releaseObjects]; + objc_autoreleasePoolPop(pool); } #else /* * iOS does not provide environ and Apple does not allow using * _NSGetEnviron on iOS. Therefore, we just get a few common * variables from the environment which applications might * expect. */ + pool = objc_autoreleasePoolPush(); + if ((env = getenv("HOME")) != NULL) [environment setObject: [OFString stringWithUTF8String: env] forKey: @"HOME"]; if ((env = getenv("PATH")) != NULL) @@ -183,12 +186,13 @@ forKey: @"TMPDIR"]; if ((env = getenv("USER")) != NULL) [environment setObject: [OFString stringWithUTF8String: env] forKey: @"USER"]; + + objc_autoreleasePoolPop(pool); #endif - [pool release]; [environment makeImmutable]; } @catch (id e) { [self release]; @throw e; @@ -198,11 +202,11 @@ } - (void)setArgumentCount: (int*)argc_ andArgumentValues: (char***)argv_ { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); int i; [programName release]; [arguments release]; @@ -219,11 +223,11 @@ [OFString stringWithCString: (*argv)[i] encoding: OF_STRING_ENCODING_NATIVE]]; [arguments makeImmutable]; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)getArgumentCount: (int**)argc_ andArgumentValues: (char****)argv_ {