xref: /reactos/sdk/lib/cpprt/new_nothrow.cpp (revision c2c66aff)
1 /*
2  * PROJECT:         ReactOS C++ runtime library
3  * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE:         nothrow version of the new operators
5  * PROGRAMMER:      Thomas Faber (thomas.faber@reactos.org)
6  */
7 
8 #include <new>
9 
10 void* operator new (std::size_t) throw(std::bad_alloc);
11 void* operator new[] (std::size_t) throw(std::bad_alloc);
12 
13 const std::nothrow_t std::nothrow;
14 
operator new(std::size_t size,const std::nothrow_t & nothrow_constant)15 void* operator new (std::size_t size, const std::nothrow_t& nothrow_constant) throw()
16 {
17     try
18     {
19         return operator new (size);
20     }
21     catch (std::bad_alloc)
22     {
23         return NULL;
24     }
25 }
26 
operator new[](std::size_t size,const std::nothrow_t & nothrow_constant)27 void* operator new[] (std::size_t size, const std::nothrow_t& nothrow_constant) throw()
28 {
29     try
30     {
31         return operator new[] (size);
32     }
33     catch (std::bad_alloc)
34     {
35         return NULL;
36     }
37 }
38