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.

75 lines
2.0 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2001 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: MemoryTracking.h
  6. * Content: Debug memory tracking for detecting leaks, overruns, etc.
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 11/14/2001 masonb Created
  12. *
  13. ***************************************************************************/
  14. #ifndef __MEMORYTRACKING_H__
  15. #define __MEMORYTRACKING_H__
  16. #ifdef DBG
  17. BOOL DNMemoryTrackInitialize(DWORD_PTR dwpMaxMemUsage);
  18. void DNMemoryTrackDeinitialize();
  19. BOOL DNMemoryTrackDumpLeaks();
  20. void* DNMemoryTrackHeapAlloc(DWORD_PTR MemorySize);
  21. void DNMemoryTrackHeapFree(void* pMemory);
  22. void DNMemoryTrackValidateMemory();
  23. #define DNMalloc( size ) DNMemoryTrackHeapAlloc( size )
  24. #define DNFree( pData ) DNMemoryTrackHeapFree( pData )
  25. #define DNValidateMemory() DNMemoryTrackValidateMemory()
  26. #else // !DBG
  27. #ifdef DPNBUILD_FIXEDMEMORYMODEL
  28. BOOL DNMemoryTrackInitialize(DWORD_PTR dwpMaxMemUsage);
  29. void DNMemoryTrackDeinitialize();
  30. extern HANDLE g_hMemoryHeap;
  31. #define DNMemoryTrackGetHeap() (g_hMemoryHeap)
  32. #else // ! DPNBUILD_FIXEDMEMORYMODEL
  33. #define DNMemoryTrackInitialize(dwMaxMemUsage) (TRUE)
  34. #define DNMemoryTrackDeinitialize()
  35. #define DNMemoryTrackGetHeap GetProcessHeap
  36. #endif // ! DPNBUILD_FIXEDMEMORYMODEL
  37. #define DNMalloc( size ) HeapAlloc( DNMemoryTrackGetHeap(), 0, size )
  38. #define DNFree( pData ) HeapFree( DNMemoryTrackGetHeap(), 0, pData )
  39. #define DNValidateMemory()
  40. #endif // DBG
  41. #ifdef DPNBUILD_PREALLOCATEDMEMORYMODEL
  42. void DNMemoryTrackAllowAllocations(BOOL fAllow);
  43. extern BOOL g_fAllocationsAllowed;
  44. #define DNMemoryTrackAreAllocationsAllowed() (g_fAllocationsAllowed)
  45. #else // ! DPNBUILD_PREALLOCATEDMEMORYMODEL
  46. #define DNMemoryTrackAllowAllocations( fAllow )
  47. #define DNMemoryTrackAreAllocationsAllowed() (TRUE)
  48. #endif // ! DPNBUILD_PREALLOCATEDMEMORYMODEL
  49. #endif // __MEMORYTRACKING_H__