Chromium Code Reviews| Index: base/process/memory_mac.mm |
| diff --git a/base/process/memory_mac.mm b/base/process/memory_mac.mm |
| index 3e281cd8e3ca355ae5b2eb0581acb1c3bafbb71b..1cf43da53d237652e9d616cadf256d5a3be814a2 100644 |
| --- a/base/process/memory_mac.mm |
| +++ b/base/process/memory_mac.mm |
| @@ -502,26 +502,44 @@ id oom_killer_allocWithZone(id self, SEL _cmd, NSZone* zone) |
| } // namespace |
| -void* UncheckedMalloc(size_t size) { |
| +bool UncheckedMalloc(size_t size, void** result) { |
| if (g_old_malloc) { |
| #if ARCH_CPU_32_BITS |
| ScopedClearErrno clear_errno; |
| ThreadLocalBooleanAutoReset flag(g_unchecked_alloc.Pointer(), true); |
| #endif // ARCH_CPU_32_BITS |
| - return g_old_malloc(malloc_default_zone(), size); |
| + return *result = g_old_malloc(malloc_default_zone(), size); |
| + } else { |
| + *result = malloc(size); |
| } |
| - return malloc(size); |
| + |
| + return *result; |
| } |
| -void* UncheckedCalloc(size_t num_items, size_t size) { |
| +bool UncheckedCalloc(size_t num_items, size_t size, void** result) { |
| if (g_old_calloc) { |
| #if ARCH_CPU_32_BITS |
| ScopedClearErrno clear_errno; |
| ThreadLocalBooleanAutoReset flag(g_unchecked_alloc.Pointer(), true); |
| #endif // ARCH_CPU_32_BITS |
| - return g_old_calloc(malloc_default_zone(), num_items, size); |
| + *result = g_old_calloc(malloc_default_zone(), num_items, size); |
| + } else { |
| + *result = calloc(num_items, size); |
| } |
| - return calloc(num_items, size); |
| + |
| + return *result; |
|
jar (doing other things)
2014/02/26 03:59:52
nit: Clearer might be:
return NULL != *result;
|
| +} |
| + |
| +void* UncheckedMalloc(size_t size) { |
| + void* address; |
| + bool result ALLOW_UNUSED = UncheckedMalloc(size, &address); |
|
jar (doing other things)
2014/02/26 03:59:52
It is a bit distressing to see both a bool return,
|
| + return address; |
| +} |
| + |
| +void* UncheckedCalloc(size_t num_items, size_t size) { |
| + void* address; |
| + bool result ALLOW_UNUSED = UncheckedCalloc(num_items, size, &address); |
| + return address; |
| } |
| void EnableTerminationOnOutOfMemory() { |