Don't include <exception_defines.h>
[binutils.git] / ld / testsuite / ld-elf / new.cc
blob513cf2f3ad62596bd465ef028d6962c6b8ca8c76
1 #include <new>
3 using std::bad_alloc;
5 extern "C" void *malloc (std::size_t);
6 extern "C" void abort (void);
8 void *
9 operator new (std::size_t sz, const std::nothrow_t&) throw()
11 void *p;
13 /* malloc (0) is unpredictable; avoid it. */
14 if (sz == 0)
15 sz = 1;
16 p = (void *) malloc (sz);
17 return p;
20 void *
21 operator new (std::size_t sz) throw (std::bad_alloc)
23 void *p;
25 /* malloc (0) is unpredictable; avoid it. */
26 if (sz == 0)
27 sz = 1;
28 p = (void *) malloc (sz);
29 while (p == 0)
31 ::abort();
34 return p;
37 void*
38 operator new[] (std::size_t sz) throw (std::bad_alloc)
40 return ::operator new(sz);
43 void *
44 operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
46 return ::operator new(sz, nothrow);