Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -82,13 +82,13 @@ - addItem: (void*)item { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException newWithClass: isa]; - data = [self resizeMem: data - toNItems: count + 1 - withSize: itemsize]; + data = [self resizeMemory: data + toNItems: count + 1 + withSize: itemsize]; memcpy(data + count++ * itemsize, item, itemsize); return self; } @@ -97,13 +97,13 @@ fromCArray: (void*)carray { if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; - data = [self resizeMem: data - toNItems: count + nitems - withSize: itemsize]; + data = [self resizeMemory: data + toNItems: count + nitems + withSize: itemsize]; memcpy(data + count * itemsize, carray, nitems * itemsize); count += nitems; return self; @@ -112,13 +112,13 @@ - removeNItems: (size_t)nitems { if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; - data = [self resizeMem: data - toNItems: count - nitems - withSize: itemsize]; + data = [self resizeMemory: data + toNItems: count - nitems + withSize: itemsize]; count -= nitems; return self; } @@ -213,12 +213,12 @@ @throw [OFOutOfRangeException newWithClass: isa]; nsize = ((count + 1) * itemsize + lastpagebyte) & ~lastpagebyte; if (size != nsize) - data = [self resizeMem: data - toSize: nsize]; + data = [self resizeMemory: data + toSize: nsize]; memcpy(data + count++ * itemsize, item, itemsize); size = nsize; return self; @@ -233,12 +233,12 @@ @throw [OFOutOfRangeException newWithClass: isa]; nsize = ((count + nitems) * itemsize + lastpagebyte) & ~lastpagebyte; if (size != nsize) - data = [self resizeMem: data - toSize: nsize]; + data = [self resizeMemory: data + toSize: nsize]; memcpy(data + count * itemsize, carray, nitems * itemsize); count += nitems; size = nsize; @@ -253,12 +253,12 @@ @throw [OFOutOfRangeException newWithClass: isa]; nsize = ((count - nitems) * itemsize + lastpagebyte) & ~lastpagebyte; if (size != nsize) - data = [self resizeMem: data - toSize: nsize]; + data = [self resizeMemory: data + toSize: nsize]; count -= nitems; size = nsize; return self; Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -66,12 +66,12 @@ self = [super init]; size = 4096; @try { - data = [self allocNItems: size - withSize: sizeof(OFList*)]; + data = [self allocMemoryForNItems: size + withSize: sizeof(OFList*)]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. Compiler bug? * Anyway, set size to 0 so that [self dealloc] works. */ @@ -96,12 +96,12 @@ } size = (size_t)1 << hashsize; @try { - data = [self allocNItems: size - withSize: sizeof(OFList*)]; + data = [self allocMemoryForNItems: size + withSize: sizeof(OFList*)]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. Compiler bug? * Anyway, set size to 0 so that [self dealloc] works. */ Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -76,11 +76,11 @@ @end /** * An OFException indicating there is not enough memory available. */ -@interface OFNoMemException: OFException +@interface OFOutOfMemoryException: OFException { size_t req_size; } /** @@ -108,11 +108,11 @@ @end /** * An OFException indicating the given memory is not part of the object. */ -@interface OFMemNotPartOfObjException: OFException +@interface OFMemoryNotPartOfObjectException: OFException { void *pointer; } /** Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -100,11 +100,11 @@ { return string; } @end -@implementation OFNoMemException +@implementation OFOutOfMemoryException + newWithClass: (Class)class_ andSize: (size_t)size { return [[self alloc] initWithClass: class_ andSize: size]; @@ -136,11 +136,11 @@ { return req_size; } @end -@implementation OFMemNotPartOfObjException +@implementation OFMemoryNotPartOfObjectException + newWithClass: (Class)class_ andPointer: (void*)ptr { return [[self alloc] initWithClass: class_ andPointer: ptr]; Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -61,12 +61,13 @@ return last; } - (of_list_object_t*)append: (id)obj { - of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o; + o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = NULL; o->prev = last; if (last != NULL) @@ -82,12 +83,13 @@ return o; } - (of_list_object_t*)prepend: (id)obj { - of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o; + o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = first; o->prev = NULL; if (first != NULL) @@ -104,12 +106,13 @@ } - (of_list_object_t*)insert: (id)obj before: (of_list_object_t*)listobj { - of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o; + o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = listobj; o->prev = listobj->prev; if (listobj->prev != NULL) @@ -127,12 +130,13 @@ } - (of_list_object_t*)insert: (id)obj after: (of_list_object_t*)listobj { - of_list_object_t *o = [self allocWithSize: sizeof(of_list_object_t)]; + of_list_object_t *o; + o = [self allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = obj; o->next = listobj->next; o->prev = listobj; if (listobj->next != NULL) @@ -162,11 +166,11 @@ last = listobj->prev; if (retain_and_release) [listobj->object release]; - [self freeMem: listobj]; + [self freeMemory: listobj]; return self; } - (size_t)count @@ -212,11 +216,11 @@ o = NULL; prev = NULL; @try { for (iter = first; iter != NULL; iter = iter->next) { - o = [new allocWithSize: sizeof(of_list_object_t)]; + o = [new allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = iter->object; o->next = NULL; o->prev = prev; if (new->first == NULL) Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -100,12 +100,12 @@ if (hashsize < 8 || hashsize >= 28) @throw [OFInvalidArgumentException newWithClass: isa andSelector: _cmd]; newsize = (size_t)1 << hashsize; - newdata = [self allocNItems: newsize - withSize: sizeof(OFList*)]; + newdata = [self allocMemoryForNItems: newsize + withSize: sizeof(OFList*)]; memset(newdata, 0, newsize * sizeof(OFList*)); for (i = 0; i < size; i++) { if (OF_LIKELY(data[i] == nil)) continue; @@ -122,11 +122,11 @@ } [data[i] release]; } - [self freeMem: data]; + [self freeMemory: data]; data = newdata; size = newsize; return self; } Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -41,11 +41,11 @@ - setToCString: (const char*)str { size_t len; if (string != NULL) - [self freeMem: string]; + [self freeMemory: string]; len = strlen(str); switch (of_string_check_utf8(str, len)) { case 1: @@ -58,11 +58,11 @@ @throw [OFInvalidEncodingException newWithClass: isa]; } length = len; - string = [self allocWithSize: length + 1]; + string = [self allocMemoryWithSize: length + 1]; memcpy(string, str, length + 1); return self; } @@ -83,12 +83,12 @@ break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } - string = [self resizeMem: string - toSize: length + strlength + 1]; + string = [self resizeMemory: string + toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; return self; } @@ -118,11 +118,11 @@ /* * This is only the most likely error to happen. * Unfortunately, as errno isn't always thread-safe, there's * no good way for us to find out what really happened. */ - @throw [OFNoMemException newWithClass: isa]; + @throw [OFOutOfMemoryException newWithClass: isa]; @try { [self appendCString: t]; } @finally { free(t); @@ -267,15 +267,15 @@ for (i = 0, last = 0; i <= length - str_len; i++) { if (memcmp(string + i, str_c, str_len)) continue; @try { - tmp = [self resizeMem: tmp - toSize: tmp_len + i - last + - repl_len + 1]; + tmp = [self resizeMemory: tmp + toSize: tmp_len + i - last + + repl_len + 1]; } @catch (OFException *e) { - [self freeMem: tmp]; + [self freeMemory: tmp]; @throw e; } memcpy(tmp + tmp_len, string + last, i - last); memcpy(tmp + tmp_len + i - last, repl_c, repl_len); tmp_len += i - last + repl_len; @@ -282,22 +282,22 @@ i += str_len - 1; last = i + 1; } @try { - tmp = [self resizeMem: tmp - toSize: tmp_len + length - last + 1]; + tmp = [self resizeMemory: tmp + toSize: tmp_len + length - last + 1]; } @catch (OFException *e) { - [self freeMem: tmp]; + [self freeMemory: tmp]; @throw e; } memcpy(tmp + tmp_len, string + last, length - last); tmp_len += length - last; tmp[tmp_len] = 0; - [self freeMem: string]; + [self freeMemory: string]; string = tmp; length = tmp_len; return self; } @end Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -132,41 +132,41 @@ * This is useful to add memory allocated by functions such as asprintf to the * pool so it gets free'd automatically when the object is deallocated. * * \param ptr A pointer to add to the memory pool */ -- addItemToMemoryPool: (void*)ptr; +- addMemoryToPool: (void*)ptr; /** * Allocate memory and store it in the objects memory pool so it can be 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; +- (void*)allocMemoryWithSize: (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 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 */ -- (void*)allocNItems: (size_t)nitems - withSize: (size_t)size; +- (void*)allocMemoryForNItems: (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 * \param size The new size for the memory chunk * \return A pointer to the resized memory chunk */ -- (void*)resizeMem: (void*)ptr - toSize: (size_t)size; +- (void*)resizeMemory: (void*)ptr + toSize: (size_t)size; /** * Resize memory in the memory pool to a specific number of items of a * specified size. * @@ -173,20 +173,20 @@ * \param ptr A pointer to the already allocated memory * \param nitems The number of items to resize to * \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 - withSize: (size_t)size; +- (void*)resizeMemory: (void*)ptr + toNItems: (size_t)nitems + withSize: (size_t)size; /** * Frees allocated memory and removes it from the memory pool. * * \param ptr A pointer to the allocated memory */ -- freeMem: (void*)ptr; +- freeMemory: (void*)ptr; /** * Increases the retain count. */ - retain; Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -195,11 +195,11 @@ { /* Classes containing data should reimplement this! */ return (uint32_t)(intptr_t)self; } -- addItemToMemoryPool: (void*)ptr +- addMemoryToPool: (void*)ptr { void **memchunks; size_t memchunks_size; memchunks_size = PRE_IVAR->memchunks_size + 1; @@ -208,21 +208,21 @@ memchunks_size > SIZE_MAX / sizeof(void*)) @throw [OFOutOfRangeException newWithClass: isa]; if ((memchunks = realloc(PRE_IVAR->memchunks, memchunks_size * sizeof(void*))) == NULL) - @throw [OFNoMemException newWithClass: isa - andSize: memchunks_size]; + @throw [OFOutOfMemoryException newWithClass: isa + andSize: memchunks_size]; PRE_IVAR->memchunks = memchunks; PRE_IVAR->memchunks[PRE_IVAR->memchunks_size] = ptr; PRE_IVAR->memchunks_size = memchunks_size; return self; } -- (void*)allocWithSize: (size_t)size +- (void*)allocMemoryWithSize: (size_t)size { void *ptr, **memchunks; size_t memchunks_size; if (size == 0) @@ -233,90 +233,91 @@ if (SIZE_MAX - PRE_IVAR->memchunks_size == 0 || memchunks_size > SIZE_MAX / sizeof(void*)) @throw [OFOutOfRangeException newWithClass: isa]; if ((ptr = malloc(size)) == NULL) - @throw [OFNoMemException newWithClass: isa - andSize: size]; + @throw [OFOutOfMemoryException newWithClass: isa + andSize: size]; if ((memchunks = realloc(PRE_IVAR->memchunks, memchunks_size * sizeof(void*))) == NULL) { free(ptr); - @throw [OFNoMemException newWithClass: isa - andSize: memchunks_size]; + @throw [OFOutOfMemoryException newWithClass: isa + andSize: memchunks_size]; } PRE_IVAR->memchunks = memchunks; PRE_IVAR->memchunks[PRE_IVAR->memchunks_size] = ptr; PRE_IVAR->memchunks_size = memchunks_size; return ptr; } -- (void*)allocNItems: (size_t)nitems - withSize: (size_t)size +- (void*)allocMemoryForNItems: (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 allocWithSize: nitems * size]; + return [self allocMemoryWithSize: nitems * size]; } -- (void*)resizeMem: (void*)ptr - toSize: (size_t)size +- (void*)resizeMemory: (void*)ptr + toSize: (size_t)size { void **iter; if (ptr == NULL) - return [self allocWithSize: size]; + return [self allocMemoryWithSize: size]; if (size == 0) { - [self freeMem: ptr]; + [self freeMemory: ptr]; return NULL; } iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size; while (iter-- > PRE_IVAR->memchunks) { if (OF_UNLIKELY(*iter == ptr)) { if (OF_UNLIKELY((ptr = realloc(ptr, size)) == NULL)) - @throw [OFNoMemException newWithClass: isa - andSize: size]; + @throw [OFOutOfMemoryException + newWithClass: isa + andSize: size]; *iter = ptr; return ptr; } } - @throw [OFMemNotPartOfObjException newWithClass: isa - andPointer: ptr]; + @throw [OFMemoryNotPartOfObjectException newWithClass: isa + andPointer: ptr]; } -- (void*)resizeMem: (void*)ptr - toNItems: (size_t)nitems - withSize: (size_t)size +- (void*)resizeMemory: (void*)ptr + toNItems: (size_t)nitems + withSize: (size_t)size { if (ptr == NULL) - return [self allocNItems: nitems - withSize: size]; + return [self allocMemoryForNItems: nitems + withSize: size]; if (nitems == 0 || size == 0) { - [self freeMem: ptr]; + [self freeMemory: ptr]; return NULL; } if (nitems > SIZE_MAX / size) @throw [OFOutOfRangeException newWithClass: isa]; - return [self resizeMem: ptr - toSize: nitems * size]; + return [self resizeMemory: ptr + toSize: nitems * size]; } -- freeMem: (void*)ptr; +- freeMemory: (void*)ptr; { void **iter, *last, **memchunks; size_t i, memchunks_size; iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size; @@ -354,12 +355,12 @@ return self; } } - @throw [OFMemNotPartOfObjException newWithClass: isa - andPointer: ptr]; + @throw [OFMemoryNotPartOfObjectException newWithClass: isa + andPointer: ptr]; } - retain { PRE_IVAR->retain_count++; Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -29,13 +29,13 @@ pathlen = [path length]; suffixlen = strlen(PLUGIN_SUFFIX); if ((file = malloc(pathlen + suffixlen + 1)) == NULL) { - @throw [OFNoMemException newWithClass: self - andSize: pathlen + - suffixlen + 1]; + @throw [OFOutOfMemoryException newWithClass: self + andSize: pathlen + + suffixlen + 1]; } memcpy(file, [path cString], pathlen); memcpy(file + pathlen, PLUGIN_SUFFIX, suffixlen); file[pathlen + suffixlen] = 0; Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -62,58 +62,60 @@ /* Look if there's a line or \0 in our cache */ if (cache != NULL) { for (i = 0; i < cache_len; i++) { if (OF_UNLIKELY(cache[i] == '\n' || cache[i] == '\0')) { - ret_c = [self allocWithSize: i + 1]; + ret_c = [self allocMemoryWithSize: i + 1]; memcpy(ret_c, cache, i); ret_c[i] = '\0'; @try { - tmp = [self allocWithSize: cache_len - - i - 1]; + tmp = [self + allocMemoryWithSize: cache_len - + i - 1]; } @catch (OFException *e) { - [self freeMem: ret_c]; + [self freeMemory: ret_c]; @throw e; } memcpy(tmp, cache + i + 1, cache_len - i - 1); - [self freeMem: cache]; + [self freeMemory: cache]; cache = tmp; cache_len = cache_len - i - 1; @try { ret = [OFString stringWithCString: ret_c]; } @finally { - [self freeMem: ret_c]; + [self freeMemory: ret_c]; } return ret; } } } /* Read until we get a newline or \0 */ - tmp = [self allocWithSize: pagesize]; + tmp = [self allocMemoryWithSize: pagesize]; for (;;) { @try { len = [self readNBytes: pagesize - 1 intoBuffer: tmp]; } @catch (OFException *e) { - [self freeMem: tmp]; + [self freeMemory: tmp]; @throw e; } /* Look if there's a newline or \0 */ for (i = 0; i < len; i++) { if (OF_UNLIKELY(tmp[i] == '\n' || tmp[i] == '\0')) { @try { ret_c = [self - allocWithSize: cache_len + i + 1]; + allocMemoryWithSize: cache_len + + i + 1]; } @catch (OFException *e) { - [self freeMem: tmp]; + [self freeMemory: tmp]; @throw e; } if (cache != NULL) memcpy(ret_c, cache, cache_len); memcpy(ret_c + cache_len, tmp, i); @@ -120,46 +122,47 @@ ret_c[i] = '\0'; if (i < len) { @try { tmp2 = [self - allocWithSize: len - i - 1]; + allocMemoryWithSize: len - + i - 1]; } @catch (OFException *e) { - [self freeMem: ret_c]; - [self freeMem: tmp]; + [self freeMemory: ret_c]; + [self freeMemory: tmp]; @throw e; } memcpy(tmp2, tmp + i + 1, len - i - 1); if (cache != NULL) - [self freeMem: cache]; + [self freeMemory: cache]; cache = tmp2; cache_len = len - i - 1; } else { if (cache != NULL) - [self freeMem: cache]; + [self freeMemory: cache]; cache = NULL; cache_len = 0; } - [self freeMem: tmp]; + [self freeMemory: tmp]; @try { ret = [OFString stringWithCString: ret_c]; } @finally { - [self freeMem: ret_c]; + [self freeMemory: ret_c]; } return ret; } } /* There was no newline or \0 */ @try { - cache = [self resizeMem: cache - toSize: cache_len + len]; + cache = [self resizeMemory: cache + toSize: cache_len + len]; } @catch (OFException *e) { - [self freeMem: tmp]; + [self freeMemory: tmp]; @throw e; } memcpy(cache + cache_len, tmp, len); cache_len += len; } @@ -187,11 +190,11 @@ } - clearCache { if (cache != NULL) - [self freeMem: cache]; + [self freeMemory: cache]; cache = NULL; cache_len = 0; return self; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -163,11 +163,11 @@ @throw [OFInvalidEncodingException newWithClass: c]; } @try { - string = [self allocWithSize: length + 1]; + string = [self allocMemoryWithSize: length + 1]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. * Compiler bug? Anyway, [self dealloc] will do here as * we don't reimplement dealloc. @@ -225,11 +225,11 @@ [super dealloc]; @throw [OFInvalidEncodingException newWithClass: c]; } @try { - [self addItemToMemoryPool: string]; + [self addMemoryToPool: string]; } @catch (OFException *e) { free(string); @throw e; } @@ -242,11 +242,11 @@ string = strdup([str cString]); length = [str length]; @try { - [self addItemToMemoryPool: string]; + [self addMemoryToPool: string]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. * Compiler bug? Anyway, [self dealloc] will do here as we * don't reimplement dealloc. @@ -393,16 +393,17 @@ if (memcmp(string + i, delim, delim_len)) continue; /* - * We can't use [self allocWithSize:] here as self might be a - * @""-literal. + * We can't use [self allocMemoryWithSize:] here as self might + * be a @""-literal. */ if ((tmp = malloc(i - last + 1)) == NULL) - @throw [OFNoMemException newWithClass: isa - andSize: i - last + 1]; + @throw [OFOutOfMemoryException + newWithClass: isa + andSize: i - last + 1]; memcpy(tmp, string + last, i - last); tmp[i - last] = '\0'; @try { str = [OFString stringWithCString: tmp]; } @finally { Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -263,11 +263,11 @@ newsock = [OFTCPSocket socket]; addrlen = sizeof(struct sockaddr); @try { - addr = [newsock allocWithSize: sizeof(struct sockaddr)]; + addr = [newsock allocMemoryWithSize: sizeof(struct sockaddr)]; } @catch (OFException *e) { [newsock dealloc]; @throw e; } @@ -299,11 +299,11 @@ @throw [OFNotConnectedException newWithClass: isa]; sock = INVALID_SOCKET; if (saddr != NULL) - [self freeMem: saddr]; + [self freeMemory: saddr]; saddr_len = 0; return self; } @end Index: src/OFURLEncoding.h ================================================================== --- src/OFURLEncoding.h +++ src/OFURLEncoding.h @@ -21,14 +21,14 @@ /** * Encodes a string for use in a URL. * * \return A new, autoreleased string */ -- (OFString*)urlencode; +- (OFString*)urlEncodedString; /** * Decodes a string used in a URL. * * \return A new, autoreleased string */ -- (OFString*)urldecode; +- (OFString*)urlDecodedString; @end Index: src/OFURLEncoding.m ================================================================== --- src/OFURLEncoding.m +++ src/OFURLEncoding.m @@ -21,11 +21,11 @@ /* Reference for static linking */ int _OFURLEncoding_reference; @implementation OFString (OFURLEncoding) -- (OFString*)urlencode +- (OFString*)urlEncodedString { const char *s; char *ret_c; size_t i; OFString *ret; @@ -36,12 +36,12 @@ * Worst case: 3 times longer than before. * Oh, and we can't use [self allocWithSize:] here as self might be a * @"" literal. */ if ((ret_c = malloc((length * 3) + 1)) == NULL) - @throw [OFNoMemException newWithClass: isa - andSize: (length * 3) + 1]; + @throw [OFOutOfMemoryException newWithClass: isa + andSize: (length * 3) + 1]; for (i = 0; *s != '\0'; s++) { if (isalnum(*s) || *s == '-' || *s == '_' || *s == '.') ret_c[i++] = *s; else { @@ -61,11 +61,11 @@ } return ret; } -- (OFString*)urldecode +- (OFString*)urlDecodedString { const char *s; char *ret_c, c; size_t i; int st; @@ -72,12 +72,12 @@ OFString *ret; s = string; if ((ret_c = malloc(length + 1)) == NULL) - @throw [OFNoMemException newWithClass: isa - andSize: length + 1]; + @throw [OFOutOfMemoryException newWithClass: isa + andSize: length + 1]; for (st = 0, i = 0, c = 0; *s; s++) { switch (st) { case 0: if (*s == '%') Index: src/OFXMLFactory.m ================================================================== --- src/OFXMLFactory.m +++ src/OFXMLFactory.m @@ -41,12 +41,12 @@ if ((str2 = realloc(*str, len2)) == NULL) { if (*str) free(*str); *str = NULL; - @throw [OFNoMemException newWithClass: class - andSize: len2]; + @throw [OFOutOfMemoryException newWithClass: class + andSize: len2]; } *str = str2; *len = len2; } @@ -74,12 +74,12 @@ if (SIZE_MAX - len < 1) @throw [OFOutOfRangeException newWithClass: self]; len++; if ((ret = malloc(len)) == NULL) - @throw [OFNoMemException newWithClass: self - andSize: len]; + @throw [OFOutOfMemoryException newWithClass: self + andSize: len]; @try { for (i = 0; *s; s++) { switch (*s) { case '<': @@ -172,12 +172,12 @@ if (SIZE_MAX - len < 3) @throw [OFOutOfRangeException newWithClass: self]; len += 3; if ((xml = malloc(len)) == NULL) - @throw [OFNoMemException newWithClass: self - andSize: len]; + @throw [OFOutOfMemoryException newWithClass: self + andSize: len]; i = 0; xml[i++] = '<'; memcpy(xml + i, name, strlen(name)); i += strlen(name); @@ -248,12 +248,12 @@ if (SIZE_MAX - len < 1) @throw [OFOutOfRangeException newWithClass: self]; len++; if ((ret = malloc(len)) == NULL) - @throw [OFNoMemException newWithClass: self - andSize: len]; + @throw [OFOutOfMemoryException newWithClass: self + andSize: len]; memcpy(ret, strs[0], len - 1); pos = len - 1; @try { Index: tests/OFDataArray/OFDataArray.m ================================================================== --- tests/OFDataArray/OFDataArray.m +++ tests/OFDataArray/OFDataArray.m @@ -40,35 +40,35 @@ CATCH_EXCEPTION([a addNItems: SIZE_MAX \ fromCArray: NULL], \ OFOutOfRangeException) \ \ puts("Trying to add something after that error..."); \ - p = [a allocWithSize: 4096]; \ + p = [a allocMemoryWithSize: 4096]; \ memset(p, 255, 4096); \ [a addItem: p]; \ if (!memcmp([a lastItem], p, 4096)) \ puts("[a lastItem] matches with p!"); \ else { \ puts("[a lastItem] does not match p!"); \ abort(); \ } \ - [a freeMem: p]; \ + [a freeMemory: p]; \ \ puts("Adding more data..."); \ - q = [a allocWithSize: 4096]; \ + q = [a allocMemoryWithSize: 4096]; \ memset(q, 42, 4096); \ [a addItem: q]; \ if (!memcmp([a lastItem], q, 4096)) \ puts("[a lastItem] matches with q!"); \ else { \ puts("[a lastItem] does not match q!"); \ abort(); \ } \ - [a freeMem: q]; \ + [a freeMemory: q]; \ \ puts("Adding multiple items at once..."); \ - p = [a allocWithSize: 8192]; \ + p = [a allocMemoryWithSize: 8192]; \ memset(p, 64, 8192); \ [a addNItems: 2 \ fromCArray: p]; \ if (!memcmp([a lastItem], [a itemAtIndex: [a count] - 2], 4096) && \ !memcmp([a itemAtIndex: [a count] - 2], p, 4096)) \ @@ -77,11 +77,11 @@ else { \ puts("[a lastItem], [a itemAtIndex: [a count] - 2] " \ "and p do not match!"); \ abort(); \ } \ - [a freeMem: p]; \ + [a freeMemory: p]; \ \ i = [a count]; \ puts("Removing 2 items..."); \ [a removeNItems: 2]; \ if ([a count] + 2 != i) { \ Index: tests/OFObject/OFObject.m ================================================================== --- tests/OFObject/OFObject.m +++ tests/OFObject/OFObject.m @@ -37,67 +37,69 @@ void *p, *q, *r; /* Test freeing memory not allocated by obj */ puts("Freeing memory not allocated by object (should throw an " "exception)..."); - CATCH_EXCEPTION([obj freeMem: NULL], OFMemNotPartOfObjException) + CATCH_EXCEPTION([obj freeMemory: NULL], + OFMemoryNotPartOfObjectException) /* Test allocating memory */ puts("Allocating memory through object..."); - p = [obj allocWithSize: 4096]; + p = [obj allocMemoryWithSize: 4096]; puts("Allocated 4096 bytes."); /* Test freeing the just allocated memory */ puts("Freeing just allocated memory..."); - [obj freeMem: p]; + [obj freeMemory: p]; puts("Free'd."); /* It shouldn't be recognized as part of our obj anymore */ puts("Trying to free it again (should throw an exception)..."); - CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException) + CATCH_EXCEPTION([obj freeMemory: p], OFMemoryNotPartOfObjectException) /* Test multiple memory chunks */ puts("Allocating 3 chunks of memory..."); - p = [obj allocWithSize: 4096]; - q = [obj allocWithSize: 4096]; - r = [obj allocWithSize: 4096]; + p = [obj allocMemoryWithSize: 4096]; + q = [obj allocMemoryWithSize: 4096]; + r = [obj allocMemoryWithSize: 4096]; puts("Allocated 3 * 4096 bytes."); /* Free them */ puts("Now freeing them..."); - [obj freeMem: p]; - [obj freeMem: q]; - [obj freeMem: r]; + [obj freeMemory: p]; + [obj freeMemory: q]; + [obj freeMemory: r]; puts("Freed them all."); /* Try to free again */ puts("Now trying to free them again..."); - CATCH_EXCEPTION([obj freeMem: p], OFMemNotPartOfObjException) - CATCH_EXCEPTION([obj freeMem: q], OFMemNotPartOfObjException) - CATCH_EXCEPTION([obj freeMem: r], OFMemNotPartOfObjException) + CATCH_EXCEPTION([obj freeMemory: p], OFMemoryNotPartOfObjectException) + CATCH_EXCEPTION([obj freeMemory: q], OFMemoryNotPartOfObjectException) + CATCH_EXCEPTION([obj freeMemory: r], OFMemoryNotPartOfObjectException) puts("Got all 3!"); puts("Trying to allocate more memory than possible..."); - CATCH_EXCEPTION(p = [obj allocWithSize: SIZE_MAX], OFNoMemException) + CATCH_EXCEPTION(p = [obj allocMemoryWithSize: SIZE_MAX], + OFOutOfMemoryException) puts("Allocating 1 byte..."); - p = [obj allocWithSize: 1]; + p = [obj allocMemoryWithSize: 1]; puts("Trying to resize that 1 byte to more than possible..."); - CATCH_EXCEPTION(p = [obj resizeMem: p - toSize: SIZE_MAX], - OFNoMemException) + CATCH_EXCEPTION(p = [obj resizeMemory: p + toSize: SIZE_MAX], + OFOutOfMemoryException) puts("Trying to resize NULL to 1024 bytes..."); - p = [obj resizeMem: NULL - toSize: 1024]; - [obj freeMem: p]; + p = [obj resizeMemory: NULL + toSize: 1024]; + [obj freeMemory: p]; puts("Trying to resize memory that is not part of object..."); - CATCH_EXCEPTION(p = [obj resizeMem: (void*)1 - toSize: 1024], - OFMemNotPartOfObjException) + CATCH_EXCEPTION(p = [obj resizeMemory: (void*)1 + toSize: 1024], + OFMemoryNotPartOfObjectException) /* TODO: Test if freeing object frees all memory */ return 0; } Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -107,14 +107,15 @@ CHECK([[a objectAtIndex: j++] isEqual: @""]) CHECK([[a objectAtIndex: j++] isEqual: @"baz"]) CHECK([[a objectAtIndex: j++] isEqual: @""]) CHECK([[a objectAtIndex: j++] isEqual: @""]) - CHECK([[@"foo\"ba'_$" urlencode] isEqual: @"foo%22ba%27_%24"]) - CHECK([[@"foo%20bar%22%24" urldecode] isEqual: @"foo bar\"$"]) - CHECK_EXCEPT([@"foo%bar" urldecode], OFInvalidEncodingException) - CHECK_EXCEPT([@"foo%FFbar" urldecode], OFInvalidEncodingException) + CHECK([[@"foo\"ba'_$" urlEncodedString] isEqual: @"foo%22ba%27_%24"]) + CHECK([[@"foo%20bar%22%24" urlDecodedString] isEqual: @"foo bar\"$"]) + CHECK_EXCEPT([@"foo%bar" urlDecodedString], OFInvalidEncodingException) + CHECK_EXCEPT([@"foo%FFbar" urlDecodedString], + OFInvalidEncodingException) s1 = [@"asd fo asd fofo asd" mutableCopy]; [s1 replaceOccurrencesOfString: @"fo" withString: @"foo"]; CHECK([s1 isEqual: @"asd foo asd foofoo asd"])