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.

28 lines
642 B

  1. // newop2 operator new(size_t, const nothrow_t&) for Microsoft C++
  2. #include <cstdlib>
  3. #include <new>
  4. _C_LIB_DECL
  5. int __cdecl _callnewh(size_t count) _THROW1(_STD bad_alloc);
  6. _END_C_LIB_DECL
  7. void *__cdecl operator new(size_t count,
  8. const std::nothrow_t&) _THROW0()
  9. { // try to allocate count bytes
  10. void *p;
  11. _TRY_BEGIN
  12. while ((p = malloc(count)) == 0)
  13. { // buy more memory or return null pointer
  14. if (_callnewh(count) == 0)
  15. break;
  16. }
  17. _CATCH_ALL
  18. p = 0;
  19. _CATCH_END
  20. return (p);
  21. }
  22. /*
  23. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  24. * Consult your license regarding permissions and restrictions.
  25. V3.10:0009 */