Fixed problems that emerged in list.
[xlqstl.git] / new.cxx
blob743dbcc44e78e6699ccfa7ad247ce133859a1160
1 #include "new"
2 #include "cstdlib"
4 namespace std {
6 const nothrow_t nothrow = {};
8 const char *bad_alloc::what()
10 return "memory full";
15 static void *base_new(std::size_t size)
17 void *ptr;
18 ptr = std::malloc(size);
19 if (ptr){
20 return ptr;
21 } else {
22 throw std::bad_alloc();
26 void *operator new (std::size_t size)
28 return base_new(size);
31 void *operator new[] (std::size_t size)
33 return base_new(size);
36 void operator delete (void *p) throw()
38 free(p);
41 void operator delete[] (void *p) throw()
43 free(p);
46 void *operator new (std::size_t, void *p) throw()
48 return p;
51 void *operator new[] (std::size_t, void *p) throw()
53 return p;
56 void *operator new (std::size_t size, std::nothrow_t) throw()
58 return std::malloc(size);
61 void *operator new[] (std::size_t size, std::nothrow_t) throw()
63 return std::malloc(size);