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) { 10 abort(); 11 } 12 return p; 13 } 14 15 void* operator new[](std::size_t size) 16 { 17 void* p = malloc(size); 18 if (p == NULL) { 19 abort(); 20 } 21 return p; 22 } 23 24 void operator delete(void* ptr) 25 { 26 free(ptr); 27 } 28 29 void operator delete[](void* ptr) 30 { 31 free(ptr); 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 { 46 free(ptr); 47 } 48 49 void operator delete[](void* ptr, const std::nothrow_t&) 50 { 51 free(ptr); 52 } 53 54 55 56 57 58