Defined in header
new_p the new global new-handler function and returns the previously installed new-handler.
The new-handler function is the function called by allocation functions whenever a memory allocation attempt fails. Its intended purpose is one of three things:
1) make more memory available
2) terminate the program (e.g. by calling std::terminate)
3) throw exception of type std::bad_alloc or derived from std::bad_alloc
If new-handler returns, the allocation function repeats the previously-failed allocation attempt and calls the new-handler again if the allocation fails again. To end the loop, new-handler may call std::set_new_handler(nullptr): if, after a failed allocation attempt, allocation function finds that std::get_new_handler returns a null pointer value, it will throw std::bad_alloc.
At program startup, new-handler is a null pointer.
|new_p||-||pointer to function of type std::new_handler, or null pointer|
The previously-installed new handler, or a null pointer value if none was installed.
Memory allocation failed, terminating std::bad_alloc
| allocation functions |
| registers a new handler |
| function pointer type of the new handler |
| exception thrown when memory allocation fails |