blob: ddd3dba5ba01c4b52836150d2cf570928089870e [file] [log] [blame]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -07001#include "new"
2#include <stdlib.h>
3
4const std::nothrow_t std::nothrow = {};
5
6void* operator new(std::size_t size)
7{
8 void* p = malloc(size);
9 if (p == NULL) {
David 'Digit' Turner7c725132011-06-14 21:58:55 +020010 abort();
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070011 }
12 return p;
13}
14
15void* operator new[](std::size_t size)
16{
17 void* p = malloc(size);
18 if (p == NULL) {
David 'Digit' Turner7c725132011-06-14 21:58:55 +020019 abort();
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070020 }
21 return p;
22}
23
24void operator delete(void* ptr)
25{
André Goddard Rosa8f925002010-01-30 22:26:30 -020026 free(ptr);
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070027}
28
29void operator delete[](void* ptr)
30{
André Goddard Rosa8f925002010-01-30 22:26:30 -020031 free(ptr);
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070032}
33
34void* operator new(std::size_t size, const std::nothrow_t&)
35{
36 return malloc(size);
37}
38
39void* operator new[](std::size_t size, const std::nothrow_t&)
40{
41 return malloc(size);
42}
43
44void operator delete(void* ptr, const std::nothrow_t&)
45{
André Goddard Rosa8f925002010-01-30 22:26:30 -020046 free(ptr);
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070047}
48
49void operator delete[](void* ptr, const std::nothrow_t&)
50{
André Goddard Rosa8f925002010-01-30 22:26:30 -020051 free(ptr);
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070052}
53
54
55
56
57