@@ -379,21 +379,19 @@ if (![self isKindOfClass: [OFMutableArray class]]) return [OFSubarray arrayWithArray: self range: range]; - buffer = [self allocMemoryWithSize: sizeof(*buffer) - count: range.length]; - + buffer = of_malloc(range.length, sizeof(*buffer)); @try { [self getObjects: buffer inRange: range]; ret = [OFArray arrayWithObjects: buffer count: range.length]; } @finally { - [self freeMemory: buffer]; + free(buffer); } return ret; } @@ -856,12 +854,11 @@ #ifdef OF_HAVE_BLOCKS - (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = self.count; - id *tmp = [self allocMemoryWithSize: sizeof(id) - count: count]; + id *tmp = of_malloc(count, sizeof(id)); @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { tmp[idx] = block(object, idx); @@ -868,22 +865,21 @@ }]; ret = [OFArray arrayWithObjects: tmp count: count]; } @finally { - [self freeMemory: tmp]; + free(tmp); } return ret; } - (OFArray *)filteredArrayUsingBlock: (of_array_filter_block_t)block { OFArray *ret; size_t count = self.count; - id *tmp = [self allocMemoryWithSize: sizeof(id) - count: count]; + id *tmp = of_malloc(count, sizeof(id)); @try { __block size_t i = 0; [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, @@ -893,11 +889,11 @@ }]; ret = [OFArray arrayWithObjects: tmp count: i]; } @finally { - [self freeMemory: tmp]; + free(tmp); } return ret; }