home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / new_mode.cpp < prev    next >
C/C++ Source or Header  |  1998-06-17  |  901b  |  42 lines

  1. /***
  2. *newmode.cxx - defines C++ setHandler mode
  3. *
  4. *       Copyright (c) 1994-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Defines routines to set and to query the C++ new handler mode.
  8. *
  9. *       The new handler mode flag determines whether malloc() failures will
  10. *       call the new() failure handler, or whether malloc will return NULL.
  11. *
  12. *******************************************************************************/
  13.  
  14. #include <cruntime.h>
  15. #include <new.h>
  16. #include <internal.h>
  17.  
  18. int __cdecl _set_new_mode( int nhm )
  19. {
  20.     int nhmOld;
  21.  
  22.     /*
  23.      * The only valid inputs are 0 and 1
  24.      */
  25.  
  26.     if ( ( nhm & 01 ) != nhm )
  27.         return -1;
  28.  
  29.     /*
  30.      * Set the new mode and return the old
  31.      */
  32.     nhmOld = _newmode;
  33.     _newmode = nhm;
  34.  
  35.     return nhmOld;
  36. }
  37.  
  38. int __cdecl _query_new_mode ( void )
  39. {
  40.     return _newmode;
  41. }
  42.