Thanks to visit codestin.com
Credit goes to chromium.googlesource.com

blob: 71a51d71045771c4c7e2bf46ebd8c5b83e6fd6ce [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2013 The Chromium Authors
[email protected]bac984102013-06-28 17:40:242// 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
avibeced7c2015-12-24 06:47:597#include <stddef.h>
grt5fb37b7f2015-11-06 21:56:068#include <stdlib.h>
9
[email protected]bac984102013-06-28 17:40:2410namespace base {
11
Peter Kasting134ef9af2024-12-28 02:30:0912void EnableTerminationOnOutOfMemory() {}
[email protected]bac984102013-06-28 17:40:2413
Peter Kasting134ef9af2024-12-28 02:30:0914void EnableTerminationOnHeapCorruption() {}
[email protected]bac984102013-06-28 17:40:2415
16bool AdjustOOMScore(ProcessId process, int score) {
17 return false;
18}
19
grt5fb37b7f2015-11-06 21:56:0620// UncheckedMalloc and Calloc exist so that platforms making use of
21// EnableTerminationOnOutOfMemory have a way to allocate memory without
22// crashing. This _stubs.cc file is for platforms that do not support
23// EnableTerminationOnOutOfMemory (note the empty implementation above). As
24// such, these two Unchecked.alloc functions need only trivially pass-through to
25// their respective stdlib function since those functions will return null on a
26// failure to allocate.
27
28bool UncheckedMalloc(size_t size, void** result) {
29 *result = malloc(size);
30 return *result != nullptr;
31}
32
33bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
34 *result = calloc(num_items, size);
35 return *result != nullptr;
36}
37
Dave Tapuska12897512023-01-10 14:52:0938void UncheckedFree(void* ptr) {
39 free(ptr);
40}
41
[email protected]bac984102013-06-28 17:40:2442} // namespace base