diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (patch) | |
tree | defd1cc07d16ad2f3b21154114e092d11c94c5bb /libstdc++/src/new.cpp | |
download | bionic-a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349.zip bionic-a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349.tar.gz bionic-a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349.tar.bz2 |
Initial Contributionandroid-1.0
Diffstat (limited to 'libstdc++/src/new.cpp')
-rw-r--r-- | libstdc++/src/new.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/libstdc++/src/new.cpp b/libstdc++/src/new.cpp new file mode 100644 index 0000000..8189159 --- /dev/null +++ b/libstdc++/src/new.cpp @@ -0,0 +1,65 @@ +#include "new" +#include <stdlib.h> + +const std::nothrow_t std::nothrow = {}; + +void* operator new(std::size_t size) +{ + void* p = malloc(size); + if (p == NULL) { + // abort(); + } + return p; +} + +void* operator new[](std::size_t size) +{ + void* p = malloc(size); + if (p == NULL) { + // abort(); + } + return p; +} + +void operator delete(void* ptr) +{ + if (ptr) { + free(ptr); + } +} + +void operator delete[](void* ptr) +{ + if (ptr) { + free(ptr); + } +} + +void* operator new(std::size_t size, const std::nothrow_t&) +{ + return malloc(size); +} + +void* operator new[](std::size_t size, const std::nothrow_t&) +{ + return malloc(size); +} + +void operator delete(void* ptr, const std::nothrow_t&) +{ + if (ptr) { + free(ptr); + } +} + +void operator delete[](void* ptr, const std::nothrow_t&) +{ + if (ptr) { + free(ptr); + } +} + + + + + |