Update contributors list for update of alpha-vms bfd.
[binutils.git] / ld / testsuite / ld-elf / new.cc
blobb4c888247e09bd52b99fe896ddb45a8ed0567878
1 #include <new>
2 #include <exception_defines.h>
4 using std::bad_alloc;
6 extern "C" void *malloc (std::size_t);
7 extern "C" void abort (void);
9 void *
10 operator new (std::size_t sz, const std::nothrow_t&) throw()
12 void *p;
14 /* malloc (0) is unpredictable; avoid it. */
15 if (sz == 0)
16 sz = 1;
17 p = (void *) malloc (sz);
18 return p;
21 void *
22 operator new (std::size_t sz) throw (std::bad_alloc)
24 void *p;
26 /* malloc (0) is unpredictable; avoid it. */
27 if (sz == 0)
28 sz = 1;
29 p = (void *) malloc (sz);
30 while (p == 0)
32 ::abort();
35 return p;
38 void*
39 operator new[] (std::size_t sz) throw (std::bad_alloc)
41 return ::operator new(sz);
44 void *
45 operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
47 return ::operator new(sz, nothrow);