Borland C++ reference

_new_handler

checked against scan global variable

Traps new allocation miscues.

Defined in header <new.h>

Syntax

typedef void (*pvf)();
pvf _new_handler;

Or, as an alternative, you can set using the function set_new_handler, like this:

pvf set_new_handler(pvf p);

Remarks

_new_handler contains a pointer to a function that takes no arguments and returns void. If operator new() is unable to allocate the space required, it will call the function pointed to by _new_handler; if that function returns it will try the allocation again. By default, the function pointed to by _new_handler simply terminates the application. The application can replace this handler, however, with a function that can try to free up some space. This is done by assigning directly to _new_handler or by calling the function set_new_handler, which returns a pointer to the former handler.

_new_handler is provided primarily for compatibility with C++ version 1.2. In most cases this functionality can be better provided by overloading operator new().

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • no header found
  • heading `new handler` read as `newhandler`