Leaked source code of windows server 2003
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.

35 lines
835 B

  1. /******************************************************************************
  2. *
  3. * newthrow.cpp
  4. *
  5. * Copyright (c) 1999, 2000 Microsoft Corporation. All Rights Reserved.
  6. *
  7. * Abstract:
  8. *
  9. * Contents:
  10. *
  11. *****************************************************************************/
  12. #include "dimapp.h"
  13. #include <new>
  14. #include <new.h>
  15. #pragma warning(disable:4073)
  16. #pragma init_seg(lib)
  17. int __cdecl my_new_handler(size_t) {
  18. throw MAP_EXCEPTION(E_OUTOFMEMORY);
  19. return 0;
  20. }
  21. struct _tag_g_new_handler_obj{
  22. _PNH _old_new_handler;
  23. int _old_new_mode;
  24. _tag_g_new_handler_obj() {
  25. _old_new_mode = _set_new_mode(1);
  26. _old_new_handler = _set_new_handler(my_new_handler);
  27. }
  28. ~_tag_g_new_handler_obj() {
  29. _set_new_handler(_old_new_handler);
  30. _set_new_mode(_old_new_mode);
  31. }
  32. } _g_new_handler_obj;