The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | #include "new" |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | const std::nothrow_t std::nothrow = {}; |
| 5 | |
| 6 | void* operator new(std::size_t size) |
| 7 | { |
| 8 | void* p = malloc(size); |
| 9 | if (p == NULL) { |
David 'Digit' Turner | 7c72513 | 2011-06-14 21:58:55 +0200 | [diff] [blame] | 10 | abort(); |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 11 | } |
| 12 | return p; |
| 13 | } |
| 14 | |
| 15 | void* operator new[](std::size_t size) |
| 16 | { |
| 17 | void* p = malloc(size); |
| 18 | if (p == NULL) { |
David 'Digit' Turner | 7c72513 | 2011-06-14 21:58:55 +0200 | [diff] [blame] | 19 | abort(); |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 20 | } |
| 21 | return p; |
| 22 | } |
| 23 | |
| 24 | void operator delete(void* ptr) |
| 25 | { |
André Goddard Rosa | 8f92500 | 2010-01-30 22:26:30 -0200 | [diff] [blame] | 26 | free(ptr); |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | void operator delete[](void* ptr) |
| 30 | { |
André Goddard Rosa | 8f92500 | 2010-01-30 22:26:30 -0200 | [diff] [blame] | 31 | free(ptr); |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | void* operator new(std::size_t size, const std::nothrow_t&) |
| 35 | { |
| 36 | return malloc(size); |
| 37 | } |
| 38 | |
| 39 | void* operator new[](std::size_t size, const std::nothrow_t&) |
| 40 | { |
| 41 | return malloc(size); |
| 42 | } |
| 43 | |
| 44 | void operator delete(void* ptr, const std::nothrow_t&) |
| 45 | { |
André Goddard Rosa | 8f92500 | 2010-01-30 22:26:30 -0200 | [diff] [blame] | 46 | free(ptr); |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void operator delete[](void* ptr, const std::nothrow_t&) |
| 50 | { |
André Goddard Rosa | 8f92500 | 2010-01-30 22:26:30 -0200 | [diff] [blame] | 51 | free(ptr); |
The Android Open Source Project | a27d2ba | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |