blob: cb19dfae2e6f43c6ca4f1d7700ccffd804dd07d1 [file] [log] [blame]
Elliott Hughes15b641a2014-05-14 18:18:55 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <new>
18#include <stdlib.h>
19
20const std::nothrow_t std::nothrow = {};
21
22void* operator new(std::size_t size) {
23 void* p = malloc(size);
24 if (p == NULL) {
25 abort();
26 }
27 return p;
28}
29
30void* operator new[](std::size_t size) {
31 void* p = malloc(size);
32 if (p == NULL) {
33 abort();
34 }
35 return p;
36}
37
38void operator delete(void* ptr) {
39 free(ptr);
40}
41
42void operator delete[](void* ptr) {
43 free(ptr);
44}
45
46void* operator new(std::size_t size, const std::nothrow_t&) {
47 return malloc(size);
48}
49
50void* operator new[](std::size_t size, const std::nothrow_t&) {
51 return malloc(size);
52}
53
54void operator delete(void* ptr, const std::nothrow_t&) {
55 free(ptr);
56}
57
58void operator delete[](void* ptr, const std::nothrow_t&) {
59 free(ptr);
60}