This documentation is archived and is not being maintained.


Sets a new handler mode for malloc.

int _set_new_mode(
   int newhandlermode 


New handler mode for malloc; valid value is 0 or 1.

Return Value

Returns the previous handler mode set for malloc. A return value of 1 indicates that, on failure to allocate memory, malloc previously called the new handler routine; a return value of 0 indicates that it did not. If the newhandlermode argument does not equal 0 or 1, returns –1.


The C++ _set_new_mode function sets the new handler mode for malloc. The new handler mode indicates whether, on failure, malloc is to call the new handler routine as set by _set_new_handler. By default, malloc does not call the new handler routine on failure to allocate memory. You can override this default behavior so that, when malloc fails to allocate memory, malloc calls the new handler routine in the same way that the new operator does when it fails for the same reason. For more information, see the new and delete operators in the C++ Language Reference. To override the default, call


early in your program or link with NEWMODE.OBJ.


Routine Required header Compatibility
_set_new_mode <new.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.

See Also

Memory Allocation Routines | calloc | free | realloc | _query_new_handler | _query_new_mode | Run-Time Routines and .NET Framework Equivalents