diff --git a/Source/NSArray.m b/Source/NSArray.m index f5a145907..65a66a110 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -609,7 +609,7 @@ static Class NSMutableArray_concrete_class; unsigned indentBase; NSMutableString *iBaseString; NSMutableString *iSizeString; - NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; unsigned count = [self count]; NSString *plists[count]; unsigned i; diff --git a/Source/NSAutoreleasePool.m b/Source/NSAutoreleasePool.m index ea42b1480..c1923cd17 100644 --- a/Source/NSAutoreleasePool.m +++ b/Source/NSAutoreleasePool.m @@ -93,10 +93,16 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) @implementation NSAutoreleasePool +static IMP allocImp; +static IMP initImp; + + (void) initialize { if (self == [NSAutoreleasePool class]) - ; // Anything to put here? + { + allocImp = [self methodForSelector: @selector(allocWithZone:)]; + initImp = [self instanceMethodForSelector: @selector(init)]; + } } + allocWithZone: (NSZone*)zone @@ -110,6 +116,12 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv) return NSAllocateObject (self, 0, zone); } ++ new +{ + id arp = (*allocImp)(self, @selector(allocWithZone:), NSDefaultMallocZone()); + return (*initImp)(arp, @selector(init)); +} + - init { if (!_released_head) diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index c0efed0dc..40577e95a 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -529,7 +529,7 @@ compareIt(id o1, id o2, void* context) NSMutableString *result; int size; int i; - NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSArray *keysArray = [self allKeys]; int numKeys = [keysArray count]; NSString *plists[numKeys]; @@ -610,7 +610,7 @@ compareIt(id o1, id o2, void* context) NSMutableString *iBaseString; NSMutableString *iSizeString; int i; - NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSArray *keyArray = [self allKeys]; NSMutableArray *theKeys = [NSMutableArray arrayWithArray: keyArray]; int numKeys = [theKeys count]; diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 9f4ec2539..497a9f0bf 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -448,7 +448,7 @@ static NSFileManager* defaultManager = nil; NSString *next; BOOL result; - arp = [[NSAutoreleasePool alloc] init]; + arp = [NSAutoreleasePool new]; item = [contents objectAtIndex: i]; next = [path stringByAppendingPathComponent: item]; result = [self removeFileAtPath: next handler: handler]; diff --git a/Source/NSPort.m b/Source/NSPort.m index cd83444a3..fbdd6c103 100644 --- a/Source/NSPort.m +++ b/Source/NSPort.m @@ -116,7 +116,7 @@ NSString *NSPortTimeoutException * Also - bracket with retain/release pair to prevent recursion. */ [super retain]; - arp = [[NSAutoreleasePool alloc] init]; + arp = [NSAutoreleasePool new]; [self invalidate]; [arp release]; [super release];