diff options
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); + } +} + + + + + |