@@ -149,11 +149,11 @@ length: MIN_READ_SIZE]; if (bytesRead > length) { memcpy(buffer, tmp, length); - readBuffer = of_malloc(bytesRead - length, 1); + readBuffer = of_alloc(bytesRead - length, 1); memcpy(readBuffer, tmp + length, bytesRead - length); _readBuffer = _readBufferMemory = readBuffer; _readBufferLength = bytesRead - length; @@ -641,11 +641,11 @@ char *buffer; if OF_UNLIKELY (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; - buffer = of_malloc(count, itemSize); + buffer = of_alloc(count, itemSize); @try { [self readIntoBuffer: buffer exactLength: count * itemSize]; ret = [OFData dataWithItemsNoCopy: buffer @@ -662,11 +662,11 @@ - (OFData *)readDataUntilEndOfStream { OFMutableData *data = [OFMutableData data]; size_t pageSize = [OFSystemInfo pageSize]; - char *buffer = of_malloc(1, pageSize); + char *buffer = of_alloc(1, pageSize); @try { while (!self.atEndOfStream) { size_t length; @@ -692,11 +692,11 @@ - (OFString *)readStringWithLength: (size_t)length encoding: (of_string_encoding_t)encoding { OFString *ret; - char *buffer = of_malloc(length + 1, 1); + char *buffer = of_alloc(length + 1, 1); buffer[length] = 0; @try { [self readIntoBuffer: buffer exactLength: length]; @@ -739,11 +739,11 @@ } } /* Read and see if we got a newline or \0 */ pageSize = [OFSystemInfo pageSize]; - buffer = of_malloc(1, pageSize); + buffer = of_alloc(1, pageSize); @try { if ([self lowlevelIsAtEndOfStream]) { size_t retLength; @@ -775,11 +775,11 @@ /* Look if there's a newline or \0 */ for (size_t i = 0; i < bufferLength; i++) { if OF_UNLIKELY (buffer[i] == '\n' || buffer[i] == '\0') { size_t retLength = _readBufferLength + i; - char *retCString = of_malloc(retLength, 1); + char *retCString = of_alloc(retLength, 1); if (_readBuffer != NULL) memcpy(retCString, _readBuffer, _readBufferLength); memcpy(retCString + _readBufferLength, @@ -798,11 +798,11 @@ if (bufferLength > 0) { /* * Append data to _readBuffer * to prevent loss of data. */ - readBuffer = of_malloc( + readBuffer = of_alloc( _readBufferLength + bufferLength, 1); memcpy(readBuffer, _readBuffer, _readBufferLength); @@ -820,11 +820,11 @@ @throw e; } @finally { free(retCString); } - readBuffer = of_malloc(bufferLength - i - 1, 1); + readBuffer = of_alloc(bufferLength - i - 1, 1); if (readBuffer != NULL) memcpy(readBuffer, buffer + i + 1, bufferLength - i - 1); free(_readBufferMemory); @@ -836,11 +836,11 @@ } } /* There was no newline or \0 */ if (bufferLength > 0) { - readBuffer = of_malloc(_readBufferLength + bufferLength, + readBuffer = of_alloc(_readBufferLength + bufferLength, 1); memcpy(readBuffer, _readBuffer, _readBufferLength); memcpy(readBuffer + _readBufferLength, buffer, bufferLength); @@ -977,11 +977,11 @@ } } /* Read and see if we got a delimiter or \0 */ pageSize = [OFSystemInfo pageSize]; - buffer = of_malloc(1, pageSize); + buffer = of_alloc(1, pageSize); @try { if ([self lowlevelIsAtEndOfStream]) { if (_readBuffer == NULL) { _waitingForDelimiter = false; @@ -1015,11 +1015,11 @@ if (buffer[i] == '\0') delimiterLength = 1; retLength = _readBufferLength + i + 1 - delimiterLength; - retCString = of_malloc(retLength, 1); + retCString = of_alloc(retLength, 1); if (_readBuffer != NULL && _readBufferLength <= retLength) memcpy(retCString, _readBuffer, _readBufferLength); @@ -1039,11 +1039,11 @@ if (bufferLength > 0) { /* * Append data to _readBuffer * to prevent loss of data. */ - readBuffer = of_malloc( + readBuffer = of_alloc( _readBufferLength + bufferLength, 1); memcpy(readBuffer, _readBuffer, _readBufferLength); @@ -1061,11 +1061,11 @@ @throw e; } @finally { free(retCString); } - readBuffer = of_malloc(bufferLength - i - 1, 1); + readBuffer = of_alloc(bufferLength - i - 1, 1); if (readBuffer != NULL) memcpy(readBuffer, buffer + i + 1, bufferLength - i - 1); free(_readBufferMemory); @@ -1077,11 +1077,11 @@ } } /* Neither the delimiter nor \0 was found */ if (bufferLength > 0) { - readBuffer = of_malloc(_readBufferLength + bufferLength, + readBuffer = of_alloc(_readBufferLength + bufferLength, 1); memcpy(readBuffer, _readBuffer, _readBufferLength); memcpy(readBuffer + _readBufferLength, buffer, bufferLength); @@ -1334,11 +1334,11 @@ #ifdef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint16_t *tmp = of_malloc(count, sizeof(uint16_t)); + uint16_t *tmp = of_alloc(count, sizeof(uint16_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); @@ -1364,11 +1364,11 @@ #ifdef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint32_t *tmp = of_malloc(count, sizeof(uint32_t)); + uint32_t *tmp = of_alloc(count, sizeof(uint32_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); @@ -1394,11 +1394,11 @@ #ifdef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint64_t *tmp = of_malloc(count, sizeof(uint64_t)); + uint64_t *tmp = of_alloc(count, sizeof(uint64_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); @@ -1424,11 +1424,11 @@ #ifdef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - float *tmp = of_malloc(count, sizeof(float)); + float *tmp = of_alloc(count, sizeof(float)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); @@ -1454,11 +1454,11 @@ #ifdef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - double *tmp = of_malloc(count, sizeof(double)); + double *tmp = of_alloc(count, sizeof(double)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); @@ -1524,11 +1524,11 @@ #ifndef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint16_t *tmp = of_malloc(count, sizeof(uint16_t)); + uint16_t *tmp = of_alloc(count, sizeof(uint16_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP16(buffer[i]); @@ -1554,11 +1554,11 @@ #ifndef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint32_t *tmp = of_malloc(count, sizeof(uint32_t)); + uint32_t *tmp = of_alloc(count, sizeof(uint32_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP32(buffer[i]); @@ -1584,11 +1584,11 @@ #ifndef OF_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - uint64_t *tmp = of_malloc(count, sizeof(uint64_t)); + uint64_t *tmp = of_alloc(count, sizeof(uint64_t)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP64(buffer[i]); @@ -1614,11 +1614,11 @@ #ifndef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - float *tmp = of_malloc(count, sizeof(float)); + float *tmp = of_alloc(count, sizeof(float)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_FLOAT(buffer[i]); @@ -1644,11 +1644,11 @@ #ifndef OF_FLOAT_BIG_ENDIAN [self writeBuffer: buffer length: size]; #else - double *tmp = of_malloc(count, sizeof(double)); + double *tmp = of_alloc(count, sizeof(double)); @try { for (size_t i = 0; i < count; i++) tmp[i] = OF_BSWAP_DOUBLE(buffer[i]); @@ -1717,11 +1717,11 @@ encoding: (of_string_encoding_t)encoding { size_t stringLength = [string cStringLengthWithEncoding: encoding]; char *buffer; - buffer = of_malloc(stringLength + 1, 1); + buffer = of_alloc(stringLength + 1, 1); @try { memcpy(buffer, [string cStringWithEncoding: encoding], stringLength); buffer[stringLength] = '\n'; @@ -1872,11 +1872,11 @@ char *readBuffer; if (length > SIZE_MAX - _readBufferLength) @throw [OFOutOfRangeException exception]; - readBuffer = of_malloc(_readBufferLength + length, 1); + readBuffer = of_alloc(_readBufferLength + length, 1); memcpy(readBuffer, buffer, length); memcpy(readBuffer + length, _readBuffer, _readBufferLength); free(_readBufferMemory); _readBuffer = _readBufferMemory = readBuffer;