memory_stubs.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2013 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. #include "base/process/memory.h"
  5. #include <stddef.h>
  6. #include <stdlib.h>
  7. namespace base {
  8. void EnableTerminationOnOutOfMemory() {
  9. }
  10. void EnableTerminationOnHeapCorruption() {
  11. }
  12. bool AdjustOOMScore(ProcessId process, int score) {
  13. return false;
  14. }
  15. // UncheckedMalloc and Calloc exist so that platforms making use of
  16. // EnableTerminationOnOutOfMemory have a way to allocate memory without
  17. // crashing. This _stubs.cc file is for platforms that do not support
  18. // EnableTerminationOnOutOfMemory (note the empty implementation above). As
  19. // such, these two Unchecked.alloc functions need only trivially pass-through to
  20. // their respective stdlib function since those functions will return null on a
  21. // failure to allocate.
  22. bool UncheckedMalloc(size_t size, void** result) {
  23. *result = malloc(size);
  24. return *result != nullptr;
  25. }
  26. bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
  27. *result = calloc(num_items, size);
  28. return *result != nullptr;
  29. }
  30. } // namespace base