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.

75 lines
1.6 KiB

  1. //
  2. // Code to help free modules from the bondage and tyranny of CRT libraries
  3. //
  4. // Include this header in a single component and #define DECL_CRTFREE.
  5. // (CPP_FUNCTIONS is the old name.)
  6. //
  7. #if defined(__cplusplus) && (defined(CPP_FUNCTIONS) || defined(DECL_CRTFREE))
  8. #ifndef UNIX
  9. void * __cdecl operator new(size_t nSize)
  10. {
  11. // Zero init just to save some headaches
  12. return (LPVOID)LocalAlloc(LPTR, nSize);
  13. }
  14. void __cdecl operator delete(void *pv)
  15. {
  16. //delete and LocalFree both handle NULL, others don't
  17. //If changed to GlobalFree or HeapFree - must check for NULL here
  18. LocalFree((HLOCAL)pv);
  19. }
  20. #endif
  21. extern "C" int __cdecl _purecall(void)
  22. {
  23. #ifdef ASSERT_MSG
  24. ASSERT_MSG(0, "purecall() hit");
  25. #endif
  26. #ifdef DEBUG
  27. DebugBreak();
  28. #endif // DEBUG
  29. return 0;
  30. }
  31. #endif // DECL_CRTFREE
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #if defined(DEFINE_FLOAT_STUFF)
  36. // If you aren't using any floating-point CRT functions and you know
  37. // you aren't performing any float conversions or arithmetic, yet the
  38. // linker wants these symbols declared, then define DEFINE_FLOAT_STUFF.
  39. //
  40. // Warning: declaring these symbols in a component that needs floating
  41. // point support from the CRT will produce undefined results. (You will
  42. // need fp support from the CRT if you simply perform fp arithmetic.)
  43. int _fltused = 0;
  44. void __cdecl _fpmath(void) { }
  45. #endif
  46. #ifdef __cplusplus
  47. };
  48. #endif
  49. //
  50. // This file should be included in a global component header
  51. // to use the following
  52. //
  53. #ifndef __CRTFREE_H_
  54. #define __CRTFREE_H_
  55. #ifdef __cplusplus
  56. #endif
  57. #endif // __CRTFREE_H_