OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/process/memory.h" |
| 6 |
| 7 namespace base { |
| 8 |
| 9 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { |
| 10 const size_t alloc_size = num_items * size; |
| 11 |
| 12 // Overflow check |
| 13 if (size && ((alloc_size / size) != num_items)) { |
| 14 result = NULL; |
| 15 return false; |
| 16 } |
| 17 |
| 18 if (!UncheckedMalloc(alloc_size, result)) |
| 19 return false; |
| 20 |
| 21 memset(result, 0, alloc_size); |
| 22 return true; |
| 23 } |
| 24 |
| 25 } |
OLD | NEW |