Index: src/OFAutoreleasePool.h ================================================================== --- src/OFAutoreleasePool.h +++ src/OFAutoreleasePool.h @@ -41,8 +41,26 @@ */ - addObject: (OFObject*)obj; /** * Releases all objects in the autorelease pool. + * + * If a garbage collector is added in the future, it will tell the GC that now + * is a good time to clean up, as this is often used after a lot of objects + * have been added to the pool that should be released before the next iteration + * of a loop, which adds objects again. Thus, it is usually a clean up call. */ - releaseObjects; + +/** + * Releases all objects in the autorelease pool and deallocates the pool. + */ +- (void)release; + +/** + * Calling drain is equivalent to calling release. + * + * If a garbage collector is added in the future, it will tell the GC that now + * is a good time to clean up. + */ +- (void)drain; @end Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -149,10 +149,20 @@ [objects release]; objects = nil; return self; } + +- (void)release +{ + [self dealloc]; +} + +- (void)drain +{ + [self dealloc]; +} - retain { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; Index: tests/OFArray.m ================================================================== --- tests/OFArray.m +++ tests/OFArray.m @@ -74,7 +74,7 @@ OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]]) EXPECT_EXCEPTION(@"Detect out of range in -[removeNItems:]", OFOutOfRangeException, [a[0] removeNObjects: [a[0] count] + 1]) - [pool release]; + [pool drain]; } Index: tests/OFDataArray.m ================================================================== --- tests/OFDataArray.m +++ tests/OFDataArray.m @@ -115,7 +115,7 @@ do_tests([OFDataArray class]); module = @"OFBigDataArray"; do_tests([OFBigDataArray class]); - [pool release]; + [pool drain]; } Index: tests/OFDictionary.m ================================================================== --- tests/OFDictionary.m +++ tests/OFDictionary.m @@ -110,7 +110,7 @@ ![dict isEqual: dict2] && [dict setObject: values[0] forKey: keys[0]] && [dict isEqual: dict2]) - [pool release]; + [pool drain]; } Index: tests/OFHashes.m ================================================================== --- tests/OFHashes.m +++ tests/OFHashes.m @@ -62,7 +62,7 @@ ofSize: 1]) EXPECT_EXCEPTION(@"Detect invalid call of -[updateWithBuffer] #2", OFHashAlreadyCalculatedException, [sha1 updateWithBuffer: "" ofSize: 1]) - [pool release]; + [pool drain]; } Index: tests/OFList.m ================================================================== --- tests/OFList.m +++ tests/OFList.m @@ -66,7 +66,7 @@ [[list first]->next->object isEqual: strings[1]] && [[list last]->object isEqual: strings[2]]) TEST(@"-[isEqual:]", [list isEqual: [[list copy] autorelease]]) - [pool release]; + [pool drain]; } Index: tests/OFObject.m ================================================================== --- tests/OFObject.m +++ tests/OFObject.m @@ -61,7 +61,7 @@ EXPECT_EXCEPTION(@"Detect resizing of memory not allocated by object", OFMemoryNotPartOfObjectException, [obj resizeMemory: (void*)1 toSize: 1024]) - [pool release]; + [pool drain]; } Index: tests/OFPlugin.m ================================================================== --- tests/OFPlugin.m +++ tests/OFPlugin.m @@ -31,7 +31,7 @@ TEST(@"+[pluginFromFile:]", (plugin = [OFPlugin pluginFromFile: @"plugin/TestPlugin"])) TEST(@"TestPlugin's -[test:]", [plugin test: 1234] == 2468) - [pool release]; + [pool drain]; } Index: tests/OFString.m ================================================================== --- tests/OFString.m +++ tests/OFString.m @@ -337,7 +337,7 @@ TEST(@"-[stringByXMLUnescapingWithHandler:]", (h = [[[EntityHandler alloc] init] autorelease]) && (s[0] = [@"x&foo;y" stringByXMLUnescapingWithHandler: h]) && [s[0] isEqual: @"xbary"]) - [pool release]; + [pool drain]; } Index: tests/OFTCPSocket.m ================================================================== --- tests/OFTCPSocket.m +++ tests/OFTCPSocket.m @@ -61,7 +61,7 @@ TEST(@"-[readNBytes:intoBuffer:]", [accepted readNBytes: 6 intoBuffer: buf] && !memcmp(buf, "Hello!", 6)) - [pool release]; + [pool drain]; } Index: tests/OFThread.m ================================================================== --- tests/OFThread.m +++ tests/OFThread.m @@ -51,7 +51,7 @@ forTLSKey: key]) TEST(@"+[objectForTLSKey:]", [[OFThread objectForTLSKey: key] isEqual: @"foo"]) - [pool release]; + [pool drain]; } Index: tests/OFXMLElement.m ================================================================== --- tests/OFXMLElement.m +++ tests/OFXMLElement.m @@ -45,7 +45,7 @@ TEST(@"-[addChild:]", [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] && [[elem[0] string] isEqual: @""]) - [pool release]; + [pool drain]; } Index: tests/OFXMLParser.m ================================================================== --- tests/OFXMLParser.m +++ tests/OFXMLParser.m @@ -184,7 +184,7 @@ withSize: 2]; } TEST(@"Checking if everything was parsed", i == 11) - [pool release]; + [pool drain]; }