1#include <new>
2#include <exception_defines.h>
3
4using std::bad_alloc;
5
6extern "C" void *malloc (std::size_t);
7extern "C" void abort (void);
8
9void *
10operator new (std::size_t sz, const std::nothrow_t&) throw()
11{
12  void *p;
13
14  /* malloc (0) is unpredictable; avoid it.  */
15  if (sz == 0)
16    sz = 1;
17  p = (void *) malloc (sz);
18  return p;
19}
20
21void *
22operator new (std::size_t sz) throw (std::bad_alloc)
23{
24  void *p;
25
26  /* malloc (0) is unpredictable; avoid it.  */
27  if (sz == 0)
28    sz = 1;
29  p = (void *) malloc (sz);
30  while (p == 0)
31    {
32      ::abort();
33    }
34
35  return p;
36}
37
38void*
39operator new[] (std::size_t sz) throw (std::bad_alloc)
40{
41  return ::operator new(sz);
42}
43
44void *
45operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
46{
47  return ::operator new(sz, nothrow);
48}
49