Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -86,11 +86,11 @@ if (SIZE_MAX - items < 1 || items + 1 > SIZE_MAX / itemsize) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMem: data toNItems: items + 1 - ofSize: itemsize]; + withSize: itemsize]; memcpy(data + items++ * itemsize, item, itemsize); return self; } @@ -101,11 +101,11 @@ if (nitems > SIZE_MAX - items || items + nitems > SIZE_MAX / itemsize) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMem: data toNItems: items + nitems - ofSize: itemsize]; + withSize: itemsize]; memcpy(data + items * itemsize, carray, nitems * itemsize); items += nitems; return self; @@ -116,11 +116,11 @@ if (nitems > items) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMem: data toNItems: items - nitems - ofSize: itemsize]; + withSize: itemsize]; items -= nitems; return self; } Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -36,12 +36,12 @@ self = [super init]; size = 4096; @try { - data = [self getMemForNItems: size - ofSize: sizeof(OFList*)]; + data = [self allocNItems: size + withSize: sizeof(OFList*)]; } @catch (OFException *e) { [self free]; @throw e; } memset(data, 0, size); @@ -62,12 +62,12 @@ } size = (size_t)1 << hashsize; @try { - data = [self getMemForNItems: size - ofSize: sizeof(OFList*)]; + data = [self allocNItems: size + withSize: sizeof(OFList*)]; } @catch (OFException *e) { [self free]; @throw e; } memset(data, 0, size); Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -61,11 +61,11 @@ return last; } - (of_list_object_t*)append: (id)obj { - of_list_object_t *o = [self getMemWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = NULL; o->prev = last; @@ -82,11 +82,11 @@ return o; } - (of_list_object_t*)prepend: (id)obj { - of_list_object_t *o = [self getMemWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = first; o->prev = NULL; @@ -104,11 +104,11 @@ } - (of_list_object_t*)insert: (id)obj before: (of_list_object_t*)listobj { - of_list_object_t *o = [self getMemWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = listobj; o->prev = listobj->prev; @@ -127,11 +127,11 @@ } - (of_list_object_t*)insert: (id)obj after: (of_list_object_t*)listobj { - of_list_object_t *o = [self getMemWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = listobj->next; o->prev = listobj; Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -144,22 +144,22 @@ * automatically when the object is free'd. * * \param size The size of the memory to allocate * \return A pointer to the allocated memory */ -- (void*)getMemWithSize: (size_t)size; +- (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. * * \param nitems The number of items to allocate * \param size The size of each item to allocate * \return A pointer to the allocated memory */ -- (void*)getMemForNItems: (size_t)nitems - ofSize: (size_t)size; +- (void*)allocNItems: (size_t)nitems + withSize: (size_t)size; /** * Resize memory in the memory pool to a specified size. * * \param ptr A pointer to the already allocated memory @@ -178,11 +178,11 @@ * \param size The size of each item to resize to * \return A pointer to the resized memory chunk */ - (void*)resizeMem: (void*)ptr toNItems: (size_t)nitems - ofSize: (size_t)size; + withSize: (size_t)size; /** * Frees allocated memory and removes it from the memory pool. * * \param ptr A pointer to the allocated memory Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -212,11 +212,11 @@ PRE_IVAR->memchunks_size = memchunks_size; return self; } -- (void*)getMemWithSize: (size_t)size +- (void*)allocWithSize: (size_t)size { void *ptr, **memchunks; size_t memchunks_size; if (size == 0) @@ -244,29 +244,29 @@ PRE_IVAR->memchunks_size = memchunks_size; return ptr; } -- (void*)getMemForNItems: (size_t)nitems - ofSize: (size_t)size +- (void*)allocNItems: (size_t)nitems + withSize: (size_t)size { if (nitems == 0 || size == 0) return NULL; if (nitems > SIZE_MAX / size) @throw [OFOutOfRangeException newWithClass: isa]; - return [self getMemWithSize: nitems * size]; + return [self allocWithSize: nitems * size]; } - (void*)resizeMem: (void*)ptr toSize: (size_t)size { void **iter; if (ptr == NULL) - return [self getMemWithSize: size]; + return [self allocWithSize: size]; if (size == 0) { [self freeMem: ptr]; return NULL; } @@ -288,17 +288,17 @@ andPointer: ptr]; } - (void*)resizeMem: (void*)ptr toNItems: (size_t)nitems - ofSize: (size_t)size + withSize: (size_t)size { size_t memsize; if (ptr == NULL) - return [self getMemForNItems: nitems - ofSize: size]; + return [self allocNItems: nitems + withSize: size]; if (nitems == 0 || size == 0) { [self freeMem: ptr]; return NULL; } Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -164,11 +164,11 @@ @throw [OFInvalidEncodingException newWithClass: c]; } @try { - string = [self getMemWithSize: length + 1]; + string = [self allocWithSize: length + 1]; } @catch (OFException *e) { [self free]; @throw e; } memcpy(string, str, length + 1); @@ -267,11 +267,11 @@ @throw [OFInvalidEncodingException newWithClass: isa]; } length = len; - string = [self getMemWithSize: length + 1]; + string = [self allocWithSize: length + 1]; memcpy(string, str, length + 1); return self; } Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -202,11 +202,11 @@ newsock = [OFTCPSocket new]; addrlen = sizeof(struct sockaddr); @try { - addr = [newsock getMemWithSize: sizeof(struct sockaddr)]; + addr = [newsock allocWithSize: sizeof(struct sockaddr)]; } @catch(id e) { [newsock free]; @throw e; } Index: tests/OFArray/OFArray.m ================================================================== --- tests/OFArray/OFArray.m +++ tests/OFArray/OFArray.m @@ -40,11 +40,11 @@ CATCH_EXCEPTION([a addNItems: SIZE_MAX \ fromCArray: NULL], \ OFOutOfRangeException) \ \ puts("Trying to add something after that error..."); \ - p = [a getMemWithSize: 4096]; \ + p = [a allocWithSize: 4096]; \ memset(p, 255, 4096); \ [a add: p]; \ if (!memcmp([a last], p, 4096)) \ puts("[a last] matches with p!"); \ else { \ @@ -52,11 +52,11 @@ abort(); \ } \ [a freeMem: p]; \ \ puts("Adding more data..."); \ - q = [a getMemWithSize: 4096]; \ + q = [a allocWithSize: 4096]; \ memset(q, 42, 4096); \ [a add: q]; \ if (!memcmp([a last], q, 4096)) \ puts("[a last] matches with q!"); \ else { \ @@ -64,11 +64,11 @@ abort(); \ } \ [a freeMem: q]; \ \ puts("Adding multiple items at once..."); \ - p = [a getMemWithSize: 8192]; \ + p = [a allocWithSize: 8192]; \ memset(p, 64, 8192); \ [a addNItems: 2 \ fromCArray: p]; \ if (!memcmp([a last], [a item: [a items] - 2], 4096) && \ !memcmp([a item: [a items] - 2], p, 4096)) \ Index: tests/OFObject/OFObject.m ================================================================== --- tests/OFObject/OFObject.m +++ tests/OFObject/OFObject.m @@ -41,11 +41,11 @@ "exception)..."); CATCH_EXCEPTION([obj freeMem: NULL], OFMemNotPartOfObjException) /* Test allocating memory */ puts("Allocating memory through object..."); - p = [obj getMemWithSize: 4096]; + p = [obj allocWithSize: 4096]; puts("Allocated 4096 bytes."); /* Test freeing the just allocated memory */ puts("Freeing just allocated memory..."); [obj freeMem: p]; @@ -55,13 +55,13 @@ puts("Trying to free it again (should throw an exception)..."); CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException) /* Test multiple memory chunks */ puts("Allocating 3 chunks of memory..."); - p = [obj getMemWithSize: 4096]; - q = [obj getMemWithSize: 4096]; - r = [obj getMemWithSize: 4096]; + p = [obj allocWithSize: 4096]; + q = [obj allocWithSize: 4096]; + r = [obj allocWithSize: 4096]; puts("Allocated 3 * 4096 bytes."); /* Free them */ puts("Now freeing them..."); [obj freeMem: p]; @@ -75,14 +75,14 @@ CATCH_EXCEPTION([obj freeMem: q], OFMemNotPartOfObjException) CATCH_EXCEPTION([obj freeMem: r], OFMemNotPartOfObjException) puts("Got all 3!"); puts("Trying to allocate more memory than possible..."); - CATCH_EXCEPTION(p = [obj getMemWithSize: SIZE_MAX], OFNoMemException) + CATCH_EXCEPTION(p = [obj allocWithSize: SIZE_MAX], OFNoMemException) puts("Allocating 1 byte..."); - p = [obj getMemWithSize: 1]; + p = [obj allocWithSize: 1]; puts("Trying to resize that 1 byte to more than possible..."); CATCH_EXCEPTION(p = [obj resizeMem: p toSize: SIZE_MAX], OFNoMemException)