@@ -44,13 +44,11 @@ retLength = length; /* * We can't use allocMemoryWithSize: here as it might be a @"" literal */ - if ((retCString = malloc(retLength)) == NULL) - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: retLength]; + retCString = of_malloc(1, retLength); for (size_t i = 0; i < length; i++) { switch (string[i]) { case '<': append = "<"; @@ -80,20 +78,17 @@ append = NULL; appendLen = 0; } if (append != NULL) { - char *newRetCString; - - if ((newRetCString = realloc(retCString, - retLength + appendLen)) == NULL) { - free(retCString); - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: retLength + - appendLen]; - } - retCString = newRetCString; + @try { + retCString = of_realloc(retCString, 1, + retLength + appendLen); + } @catch (id e) { + of_free(retCString); + @throw e; + } retLength += appendLen - 1; memcpy(retCString + j, append, appendLen); j += appendLen; } else @@ -105,10 +100,10 @@ @try { ret = [OFString stringWithUTF8String: retCString length: retLength]; } @finally { - free(retCString); + of_free(retCString); } return ret; } @end