* elflink.c (_bfd_elf_link_create_dynamic_sections): If the
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / new.cc
1 #include <new>
2
3 using std::bad_alloc;
4
5 extern "C" void *malloc (std::size_t);
6 extern "C" void abort (void);
7
8 void *
9 operator new (std::size_t sz, const std::nothrow_t&) throw()
10 {
11 void *p;
12
13 /* malloc (0) is unpredictable; avoid it. */
14 if (sz == 0)
15 sz = 1;
16 p = (void *) malloc (sz);
17 return p;
18 }
19
20 void *
21 operator new (std::size_t sz) throw (std::bad_alloc)
22 {
23 void *p;
24
25 /* malloc (0) is unpredictable; avoid it. */
26 if (sz == 0)
27 sz = 1;
28 p = (void *) malloc (sz);
29 while (p == 0)
30 {
31 ::abort();
32 }
33
34 return p;
35 }
36
37 void*
38 operator new[] (std::size_t sz) throw (std::bad_alloc)
39 {
40 return ::operator new(sz);
41 }
42
43 void *
44 operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
45 {
46 return ::operator new(sz, nothrow);
47 }
This page took 0.032918 seconds and 4 git commands to generate.