set_new_handler function — Sets handler for obtaining memory
typedef void (*new_handler)( ); new_handler set_new_handler(new_handler new_p) throw( );
The set_new_handler
function stores a function pointer for a function that obtains
additional memory from the operating system for use by the new
operator. When the default operator
new
is unable to fulfill a request to
allocate memory, it calls the handler that was set by the most
recent call to set_new_handler
.
This handler must do one of the following:
Obtain more memory from the host environment
Throw bad_alloc
(or a
type that derives from bad_alloc
)
Call abort( )
or
exit( )
to halt the
program
The return value is the pointer to the previous handler, or
0
for the first call to set_new_handler
.