Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
795 B

  1. // handler.cpp -- set_new_handler for Microsoft
  2. #include <new>
  3. typedef int (__cdecl *new_hand)(size_t);
  4. new_hand _set_new_handler(new_hand);
  5. _STD_BEGIN
  6. static new_handler _New_handler;
  7. int __cdecl _New_handler_interface(size_t) _THROW1(bad_alloc)
  8. { // interface to existing Microsoft _callnewh mechanism
  9. _New_handler();
  10. return (1);
  11. }
  12. _CRTIMP2 new_handler __cdecl set_new_handler(new_handler pnew) _THROW0()
  13. { // remove current handler
  14. _Lockit _Lock(_LOCK_MALLOC); // lock thread to ensure atomicity
  15. new_handler pold = _New_handler;
  16. _New_handler = pnew;
  17. _set_new_handler(pnew ? _New_handler_interface : 0);
  18. return (pold);
  19. }
  20. _STD_END
  21. /*
  22. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  23. * Consult your license regarding permissions and restrictions.
  24. V3.10:0009 */