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.

121 lines
2.4 KiB

  1. /***
  2. *new.h - declarations and definitions for C++ memory allocation functions
  3. *
  4. * Copyright (c) 1990-1995, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Contains the declarations for C++ memory allocation functions.
  8. *
  9. * [Public]
  10. *
  11. ****/
  12. #ifndef _INC_NEW
  13. #define _INC_NEW
  14. #ifdef __cplusplus
  15. #if !defined(_WIN32) && !defined(_MAC)
  16. #error ERROR: Only Mac or Win32 targets supported!
  17. #endif
  18. #include <stdexcpt.h> /* for class exception */
  19. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  20. #ifndef _CRTAPI1
  21. #if _MSC_VER >= 800 && _M_IX86 >= 300
  22. #define _CRTAPI1 __cdecl
  23. #else
  24. #define _CRTAPI1
  25. #endif
  26. #endif
  27. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  28. #ifndef _CRTAPI2
  29. #if _MSC_VER >= 800 && _M_IX86 >= 300
  30. #define _CRTAPI2 __cdecl
  31. #else
  32. #define _CRTAPI2
  33. #endif
  34. #endif
  35. /* Define _CRTIMP */
  36. #ifndef _CRTIMP
  37. #ifdef _NTSDK
  38. /* definition compatible with NT SDK */
  39. #define _CRTIMP
  40. #else /* ndef _NTSDK */
  41. /* current definition */
  42. #ifdef _DLL
  43. #define _CRTIMP __declspec(dllimport)
  44. #else /* ndef _DLL */
  45. #define _CRTIMP
  46. #endif /* _DLL */
  47. #endif /* _NTSDK */
  48. #endif /* _CRTIMP */
  49. /* Define __cdecl for non-Microsoft compilers */
  50. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  51. #define __cdecl
  52. #endif
  53. /* types and structures */
  54. #ifndef _SIZE_T_DEFINED
  55. typedef unsigned int size_t;
  56. #define _SIZE_T_DEFINED
  57. #endif
  58. /* default new placement operator */
  59. inline void * operator new( size_t, void * ptr ) { return ptr; }
  60. /*
  61. * new mode flag -- when set, makes malloc() behave like new()
  62. */
  63. _CRTIMP int __cdecl _query_new_mode( void );
  64. _CRTIMP int __cdecl _set_new_mode( int );
  65. #ifndef _PNH_DEFINED
  66. typedef int (__cdecl * _PNH)( size_t );
  67. #define _PNH_DEFINED
  68. #endif
  69. _CRTIMP _PNH __cdecl _query_new_handler( void );
  70. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  71. /*
  72. * ANSI C++ new_handler and set_new_handler:
  73. *
  74. * WARNING: set_new_handler is a stub function that is provided to
  75. * allow compilation of the Standard Template Library (STL).
  76. *
  77. * Do NOT use it to register a new handler. Use _set_new_handler instead.
  78. *
  79. * However, it can be called to remove the current handler:
  80. *
  81. * set_new_handler(NULL); // calls _set_new_handler(NULL)
  82. */
  83. #ifndef _ANSI_NH_DEFINED
  84. typedef void (__cdecl * new_handler) ();
  85. #define _ANSI_NH_DEFINED
  86. #endif
  87. _CRTIMP new_handler __cdecl set_new_handler(new_handler);
  88. #endif /* __cplusplus */
  89. #endif /* _INC_NEW */