Chromium Code Reviews| Index: base/process/memory.cc |
| diff --git a/base/process/memory.cc b/base/process/memory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e508c5e62ee7710c9eb11c42e715332b2a11c956 |
| --- /dev/null |
| +++ b/base/process/memory.cc |
| @@ -0,0 +1,30 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/process/memory.h" |
| + |
| +namespace base { |
| + |
| +// Defined in memory_mac.mm for Mac. |
| +#if !defined(OS_MACOSX) |
| + |
| +bool UncheckedCalloc(size_t num_items, size_t size, void** result) { |
| + const size_t alloc_size = num_items * size; |
| + |
| + // Overflow check |
| + if (size && ((alloc_size / size) != num_items)) { |
| + result = NULL; |
|
jar (doing other things)
2014/02/26 03:59:52
Should this be:
*result = NULL;
|
| + return false; |
| + } |
| + |
| + if (!UncheckedMalloc(alloc_size, result)) |
| + return false; |
| + |
| + memset(result, 0, alloc_size); |
|
jar (doing other things)
2014/02/26 03:59:52
Should this be:
memset(*result, 0, alloc_size);
I
|
| + return true; |
| +} |
| + |
| +#endif |
| + |
| +} |