@@ -634,24 +634,21 @@ char *buffer; if OF_UNLIKELY (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; - if OF_UNLIKELY ((buffer = malloc(count * itemSize)) == NULL) - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: count * itemSize]; - + buffer = of_malloc(count, itemSize); @try { [self readIntoBuffer: buffer exactLength: count * itemSize]; ret = [OFData dataWithItemsNoCopy: buffer itemSize: itemSize count: count freeWhenDone: true]; } @catch (id e) { - free(buffer); + of_free(buffer); @throw e; } return ret; }