Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -27,14 +27,14 @@ @try { array = [[OFDataArray alloc] initWithItemSize: sizeof(OFObject*)]; } @catch (OFException *e) { /* - * We can't use [super free] on OS X here. Compiler bug? - * [self free] will do here as we check for nil in free. + * We can't use [super dealloc] on OS X here. Compiler bug? + * [self dealloc] will do here as we check for nil in dealloc. */ - [self free]; + [self dealloc]; @throw e; } return self; } @@ -102,11 +102,11 @@ [array removeNItems: nobjects]; return self; } -- free +- (void)dealloc { OFObject **objs; size_t len, i; if (array != nil) { @@ -117,8 +117,8 @@ [objs[i] release]; [array release]; } - return [super free]; + [super dealloc]; } @end Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -46,11 +46,11 @@ OFList *pool_list; @try { pool_list = [OFThread objectForTLSKey: pool_list_key]; } @catch (OFNotInSetException *e) { - [e free]; + [e dealloc]; [[self alloc] init]; pool_list = [OFThread objectForTLSKey: pool_list_key]; } if ([pool_list last] == NULL) @@ -71,11 +71,11 @@ objects = nil; @try { pool_list = [OFThread objectForTLSKey: pool_list_key]; } @catch (OFNotInSetException *e) { - [e free]; + [e dealloc]; pool_list = [[OFList alloc] initWithoutRetainAndRelease]; [OFThread setObject: pool_list forTLSKey: pool_list_key]; [pool_list release]; } @@ -83,11 +83,11 @@ listobj = [pool_list append: self]; return self; } -- free +- (void)dealloc { /* * FIXME: * Maybe we should get the objects ourself, release them and then * release the pool without calling its release method? This way, @@ -96,11 +96,11 @@ if (listobj->next != NULL) [listobj->next->object release]; [[OFThread objectForTLSKey: pool_list_key] remove: listobj]; - return [super free]; + [super dealloc]; } - addToPool: (OFObject*)obj { if (objects == nil) Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -40,11 +40,11 @@ self = [super init]; if (is == 0) { c = isa; - [super free]; + [super dealloc]; @throw [OFInvalidArgumentException newWithClass: c]; } data = NULL; itemsize = is; Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -41,15 +41,15 @@ @try { data = [self allocNItems: size withSize: sizeof(OFList*)]; } @catch (OFException *e) { /* - * We can't use [super free] on OS X here. Compiler bug? - * Anyway, set size to 0 so that [self free] works. + * We can't use [super dealloc] on OS X here. Compiler bug? + * Anyway, set size to 0 so that [self dealloc] works. */ size = 0; - [self free]; + [self dealloc]; @throw e; } memset(data, 0, size * sizeof(OFList*)); return self; @@ -59,11 +59,11 @@ { self = [super init]; if (hashsize < 8 || hashsize >= 28) { Class c = isa; - [super free]; + [super dealloc]; @throw [OFInvalidArgumentException newWithClass: c andSelector: _cmd]; } size = (size_t)1 << hashsize; @@ -71,31 +71,31 @@ @try { data = [self allocNItems: size withSize: sizeof(OFList*)]; } @catch (OFException *e) { /* - * We can't use [super free] on OS X here. Compiler bug? - * Anyway, set size to 0 so that [self free] works. + * We can't use [super dealloc] on OS X here. Compiler bug? + * Anyway, set size to 0 so that [self dealloc] works. */ size = 0; - [self free]; + [self dealloc]; @throw e; } memset(data, 0, size * sizeof(OFList*)); return self; } -- free +- (void)dealloc { size_t i; for (i = 0; i < size; i++) if (data[i] != nil) [data[i] release]; - return [super free]; + [super dealloc]; } - set: (OFObject*)key to: (OFObject*)obj { Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -13,11 +13,12 @@ /** * An exception indicating an object could not be allocated. * * This exception is preallocated, as if there's no memory, no exception can - * be allocated of course. That's why you shouldn't and even can't free it. + * be allocated of course. That's why you shouldn't and even can't deallocate + *it. * * This is the only exception that is not an OFException as it's special. * It does not know for which class allocation failed and it should not be * handled like other exceptions, as the exception handling code is not * allowed to allocate ANY memory. Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -71,16 +71,16 @@ string = NULL; return self; } -- free +- (void)dealloc { if (string != NULL) free(string); - return [super free]; + [super dealloc]; } - (Class)inClass { return class; @@ -307,18 +307,18 @@ err = GET_ERR; return self; } -- free +- (void)dealloc { if (path != NULL) free(path); if (mode != NULL) free(mode); - return [super free]; + [super dealloc]; } - (const char*)cString { if (string != NULL) @@ -529,18 +529,18 @@ err = GET_SOCK_ERR; return self; } -- free +- (void)dealloc { if (node != NULL) free(node); if (service != NULL) free(node); - return [super free]; + [super dealloc]; } - (const char*)cString { if (string != NULL) @@ -593,16 +593,16 @@ err = GET_SOCK_ERR; return self; } -- free +- (void)dealloc { if (host != NULL) free(host); - return [super free]; + [super dealloc]; } - (const char*)cString { if (string != NULL) @@ -655,16 +655,16 @@ err = GET_SOCK_ERR; return self; } -- free +- (void)dealloc { if (host != NULL) free(host); - return [super free]; + [super dealloc]; } - (const char*)cString { if (string != NULL) Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -84,25 +84,25 @@ self = [super init]; if ((fp = fopen(path, mode)) == NULL) { c = isa; - [super free]; + [super dealloc]; @throw [OFOpenFileFailedException newWithClass: c andPath: path andMode: mode]; } return self; } -- free +- (void)dealloc { if (fp != NULL) fclose(fp); - return [super free]; + [super dealloc]; } - (BOOL)atEndOfFile { if (fp == NULL) Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -39,18 +39,18 @@ retain_and_release = NO; return self; } -- free +- (void)dealloc { of_list_object_t *iter; for (iter = first; iter != NULL; iter = iter->next) [iter->object release]; - return [super free]; + [super dealloc]; } - (of_list_object_t*)first { return first; Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -125,24 +125,24 @@ case 1: is_utf8 = YES; break; case -1: c = isa; - [super free]; + [super dealloc]; @throw [OFInvalidEncodingException newWithClass: c]; } @try { string = [self allocWithSize: length + 1]; } @catch (OFException *e) { /* - * We can't use [super free] on OS X here. Compiler bug? - * [self free] will do here as we don't reimplement - * free. + * We can't use [super dealloc] on OS X here. + * Compiler bug? Anyway, [self dealloc] will do here as + * we don't reimplement dealloc. */ - [self free]; + [self dealloc]; @throw e; } memcpy(string, str, length + 1); } @@ -170,17 +170,17 @@ self = [super init]; if (fmt == NULL) { c = isa; - [super free]; + [super dealloc]; @throw [OFInvalidFormatException newWithClass: c]; } if ((t = vasprintf(&string, fmt, args)) == -1) { c = isa; - [super free]; + [super dealloc]; @throw [OFInitializationFailedException newWithClass: c]; } length = t; switch (check_utf8(string, length)) { @@ -188,11 +188,11 @@ is_utf8 = YES; break; case -1: free(string); c = isa; - [super free]; + [super dealloc]; @throw [OFInvalidEncodingException newWithClass: c]; } @try { [self addToMemoryPool: string]; Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -125,29 +125,30 @@ */ - (uint32_t)hash; /** * Adds a pointer to the memory pool. + * * This is useful to add memory allocated by functions such as asprintf to the - * pool so it gets freed automatically when the object is freed. + * pool so it gets free'd automatically when the object is deallocated. * * \param ptr A pointer to add to the memory pool */ - addToMemoryPool: (void*)ptr; /** * Allocate memory and store it in the objects memory pool so it can be free'd - * automatically when the object is free'd. + * automatically when the object is deallocated. * * \param size The size of the memory to allocate * \return A pointer to the allocated memory */ - (void*)allocWithSize: (size_t)size; /** * Allocate memory for a specified number of items and store it in the objects - * memory pool so it can be free'd automatically when the object is free'd. + * memory pool so it can be free'd automatically when the object is deallocated. * * \param nitems The number of items to allocate * \param size The size of each item to allocate * \return A pointer to the allocated memory */ @@ -198,14 +199,15 @@ * \return The retain count */ - (size_t)retainCount; /** - * Decreases the retain cound and frees the object if it reaches 0. + * Decreases the retain cound and deallocates the object if it reaches 0. */ - release; /** - * Frees the object and also frees all memory allocated via its memory pool. + * Deallocates the object and also frees all memory allocated via its memory + * pool. */ -- free; +- (void)dealloc; @end Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -368,17 +368,19 @@ return PRE_IVAR->retain_count; } - release { - if (!--PRE_IVAR->retain_count) - return [self free]; + if (!--PRE_IVAR->retain_count) { + [self dealloc]; + return nil; + } return self; } -- free +- (void)dealloc { void **iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size; while (iter-- > PRE_IVAR->memchunks) free(*iter); @@ -385,8 +387,7 @@ if (PRE_IVAR->memchunks != NULL) free(PRE_IVAR->memchunks); free((char*)self - PRE_IVAR_ALIGN); - return nil; } @end Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -53,12 +53,12 @@ plugin->handle = handle; return plugin; } -- free +- (void)dealloc { dlclose(handle); - return [super free]; + [super dealloc]; } @end Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -37,16 +37,16 @@ saddr_len = 0; return self; } -- free +- (void)dealloc { if (sock != INVALID_SOCKET) close(sock); - return [super free]; + [super dealloc]; } - connectTo: (const char*)host onPort: (uint16_t)port { @@ -174,16 +174,16 @@ addrlen = sizeof(struct sockaddr); @try { addr = [newsock allocWithSize: sizeof(struct sockaddr)]; } @catch (OFException *e) { - [newsock free]; + [newsock dealloc]; @throw e; } if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) { - [newsock free]; + [newsock dealloc]; @throw [OFAcceptFailedException newWithClass: isa]; } newsock->sock = s; newsock->saddr = addr; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -51,11 +51,11 @@ id old; @try { old = [self objectForTLSKey: key]; } @catch (OFNotInSetException *e) { - [e free]; + [e dealloc]; old = nil; } #ifndef _WIN32 if (pthread_setspecific(key->key, obj)) @@ -106,11 +106,11 @@ #else if ((thread = CreateThread(NULL, 0, call_main, self, 0, NULL)) == NULL) { #endif c = isa; - [super free]; + [super dealloc]; @throw [OFInitializationFailedException newWithClass: c]; } return self; } @@ -141,11 +141,11 @@ return retval; #endif } -- free +- (void)dealloc { /* * No need to handle errors - if canceling the thread fails, we can't * do anything anyway. Most likely, it finished already or was already * canceled. @@ -157,11 +157,11 @@ TerminateThread(thread, 1); CloseHandle(thread); } #endif - return [super free]; + [super dealloc]; } @end @implementation OFTLSKey + tlsKeyWithDestructor: (void(*)(void*))destructor @@ -180,12 +180,12 @@ if (pthread_key_create(&key, destructor)) { #else if ((key = TlsAlloc()) == TLS_OUT_OF_INDEXES) { #endif c = isa; - [super free]; + [super dealloc]; @throw [OFInitializationFailedException newWithClass: c]; } return self; } @end Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -90,11 +90,11 @@ CHECK_EXCEPT(s1 = [OFString stringWithCString: "\xF0\x80\x80\xC0"], OFInvalidEncodingException) s1 = [OFString stringWithCString: "äöü€𝄞"]; CHECK(!strcmp([[s1 reverse] cString], "𝄞€üöä")) - [s1 free]; + [s1 dealloc]; /* Format tests */ s1 = [OFString stringWithFormat: "%s: %d", "test", 123]; CHECK(!strcmp([s1 cString], "test: 123"))