From a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 21 Oct 2008 07:00:00 -0700 Subject: Initial Contribution --- libstdc++/src/new.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 libstdc++/src/new.cpp (limited to 'libstdc++/src/new.cpp') 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 + +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); + } +} + + + + + -- cgit v1.1