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

  1. /***
  2. *setnewh.cpp - defines C++ set_new_handler() routine
  3. *
  4. *       Copyright (c) 1990-1997, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *       Defines C++ set_new_handler() routine.
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <stddef.h>
  12. #include <internal.h>
  13. #include <cruntime.h>
  14. #include <mtdll.h>
  15. #include <process.h>
  16. #include <new.h>
  17. #include <dbgint.h>
  18.  
  19. #define _ASSERT_OK
  20. #include <assert.h>
  21.  
  22.  
  23.  
  24. /***
  25. *new_handler set_new_handler - set the ANSI C++ new handler
  26. *
  27. *Purpose:
  28. *       Set the ANSI C++ per-thread new handler.
  29. *
  30. *Entry:
  31. *       Pointer to the new handler to be installed.
  32. *
  33. *       WARNING: set_new_handler is a stub function that is provided to
  34. *       allow compilation of the Standard Template Library (STL).
  35. *
  36. *       Do NOT use it to register a new handler. Use _set_new_handler instead.
  37. *
  38. *       However, it can be called to remove the current handler:
  39. *
  40. *           set_new_handler(NULL); // calls _set_new_handler(NULL)
  41. *
  42. *Return:
  43. *       Previous ANSI C++ new handler
  44. *
  45. *******************************************************************************/
  46.  
  47. new_handler __cdecl set_new_handler (
  48.         new_handler new_p
  49.         )
  50. {
  51.         // cannot use stub to register a new handler
  52.         assert(new_p == 0);
  53.  
  54.         // remove current handler
  55.         _set_new_handler(0);
  56.  
  57.         return 0;
  58. }
  59.  
  60.  
  61.  
  62.