@@ -181,18 +181,16 @@ if (strcmp([object objCType], objCType) != 0) return false; size = of_sizeof_type_encoding(objCType); - if ((value = malloc(size)) == NULL) - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: size]; - - if ((otherValue = malloc(size)) == NULL) { - free(value); - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: size]; + value = of_malloc(1, size); + @try { + otherValue = of_malloc(1, size); + } @catch (id e) { + of_free(value); + @throw e; } @try { [self getValue: value size: size]; @@ -199,12 +197,12 @@ [object getValue: otherValue size: size]; ret = (memcmp(value, otherValue, size) == 0); } @finally { - free(value); - free(otherValue); + of_free(value); + of_free(otherValue); } return ret; } @@ -212,14 +210,11 @@ { size_t size = of_sizeof_type_encoding(self.objCType); unsigned char *value; uint32_t hash; - if ((value = malloc(size)) == NULL) - @throw [OFOutOfMemoryException - exceptionWithRequestedSize: size]; - + value = of_malloc(1, size); @try { [self getValue: value size: size]; OF_HASH_INIT(hash); @@ -227,11 +222,11 @@ for (size_t i = 0; i < size; i++) OF_HASH_ADD(hash, value[i]); OF_HASH_FINALIZE(hash); } @finally { - free(value); + of_free(value); } return hash; } @@ -316,14 +311,11 @@ OFMutableString *ret = [OFMutableString stringWithString: @""]; [ret makeImmutable]; return ret; } @end