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.

74 lines
1.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: Alloc.h
  7. //
  8. // Contents: Allocation routines
  9. //
  10. // Classes:
  11. //
  12. // Notes:
  13. //
  14. // History: 05-Nov-97 rogerg Created.
  15. //
  16. //--------------------------------------------------------------------------
  17. #ifndef _ONESTOPALLOC_
  18. #define _ONESTOPALLOC_
  19. inline void* __cdecl operator new (size_t size);
  20. inline void __cdecl operator delete(void FAR* lpv);
  21. extern "C" void __RPC_API MIDL_user_free(IN void __RPC_FAR * ptr);
  22. extern "C" void __RPC_FAR * __RPC_API MIDL_user_allocate(IN size_t len);
  23. LPVOID ALLOC(ULONG cb);
  24. void FREE(void* pv);
  25. LPVOID REALLOC(void *pv,ULONG cb);
  26. #define ADDENTRY(lpv,size)
  27. #define FREEENTRY(lpv)
  28. #define WALKARENA()
  29. #ifdef _DEBUG
  30. #define MEMINITVALUE 0xff
  31. #define MEMFREEVALUE 0xfe
  32. // set to 1 to turn enable leak detection on, 0 for off.
  33. // must also set regkey DWORD value
  34. // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Syncmgr\debug\LeakDetection = 1
  35. #define MEMLEAKDETECTION 1
  36. #if MEMLEAKDETECTION
  37. typedef struct _MemArena{
  38. DWORD Free;
  39. void *lpv;
  40. ULONG size;
  41. ULONG Order;
  42. }MEMARENA, *LPMEMARENA;
  43. // memory leak detection apis
  44. void AddEntry( void *lpv, unsigned long size);
  45. void FreeEntry ( void *lpv );
  46. void WalkArena();
  47. #undef ADDENTRY
  48. #undef FREEENTRY
  49. #undef WALKARENA
  50. #define ADDENTRY(lpv,size) AddEntry(lpv,size)
  51. #define FREEENTRY(lpv) FreeEntry(lpv)
  52. #define WALKARENA() WalkArena()
  53. #endif // MEMLEAKDETECTION
  54. #endif // DEBUG
  55. #endif // _ONESTOPALLOC_