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.

214 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. debugmem.h
  5. Abstract:
  6. Header for debugmem.cxx
  7. Author:
  8. Richard L Firth (rfirth) 02-Feb-1995
  9. Revision History:
  10. 02-Feb-1995
  11. Created
  12. --*/
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. //
  17. // manifests
  18. //
  19. //
  20. // USE_PRIVATE_HEAP_IN_RETAIL - by default we use the process heap in the retail
  21. // build. Alternative is to use a private (wininet) heap (which we do in the
  22. // debug version if required)
  23. //
  24. #if !defined(USE_PRIVATE_HEAP_IN_RETAIL)
  25. #define USE_PRIVATE_HEAP_IN_RETAIL 0
  26. #endif
  27. //
  28. // prototypes
  29. //
  30. VOID
  31. InternetDebugMemInitialize(
  32. VOID
  33. );
  34. VOID
  35. InternetDebugMemTerminate(
  36. IN BOOL bReport
  37. );
  38. HLOCAL
  39. InternetDebugAllocMem(
  40. IN UINT Flags,
  41. IN UINT Size,
  42. IN LPSTR File,
  43. IN DWORD Line
  44. );
  45. HLOCAL
  46. InternetDebugFreeMem(
  47. IN HLOCAL hLocal,
  48. IN LPSTR File,
  49. IN DWORD Line
  50. );
  51. HLOCAL
  52. InternetDebugReAllocMem(
  53. IN HLOCAL hLocal,
  54. IN UINT Size,
  55. IN UINT Flags,
  56. IN LPSTR File,
  57. IN DWORD Line
  58. );
  59. SIZE_T
  60. InternetDebugSizeMem(
  61. IN HLOCAL hLocal,
  62. IN LPSTR File,
  63. IN DWORD Line
  64. );
  65. BOOL
  66. InternetDebugCheckMemFreed(
  67. IN BOOL bReport
  68. );
  69. BOOL
  70. InternetDebugMemReport(
  71. IN BOOL bTerminateSymbols,
  72. IN BOOL bCloseFile
  73. );
  74. //
  75. // macros
  76. //
  77. #if defined(USE_DEBUG_MEMORY)
  78. #define ALLOCATOR(Flags, Size) \
  79. InternetDebugAllocMem(Flags, Size, __FILE__, __LINE__)
  80. #define DEALLOCATOR(hLocal) \
  81. InternetDebugFreeMem(hLocal, __FILE__, __LINE__)
  82. #define REALLOCATOR(hLocal, Size, Flags) \
  83. InternetDebugReAllocMem(hLocal, Size, Flags, __FILE__, __LINE__)
  84. #define MEMORYSIZER(hLocal) \
  85. InternetDebugSizeMem(hLocal, __FILE__, __LINE__)
  86. #define INITIALIZE_DEBUG_MEMORY() \
  87. InternetDebugMemInitialize()
  88. #define TERMINATE_DEBUG_MEMORY(bReport) \
  89. InternetDebugMemTerminate(bReport)
  90. #define CHECK_MEMORY_FREED(bReport) \
  91. InternetDebugCheckMemFreed(bReport)
  92. #define REPORT_DEBUG_MEMORY(bTermSym, bCloseFile) \
  93. InternetDebugMemReport(bTermSym, bCloseFile)
  94. #else // retail version
  95. #if USE_PRIVATE_HEAP_IN_RETAIL
  96. #error no other memory allocation schemes defined
  97. #else
  98. #ifndef WININET_UNIX_PRVATE_ALLOCATOR
  99. #define ALLOCATOR(Flags, Size) \
  100. LocalAlloc(Flags, Size)
  101. #define DEALLOCATOR(hLocal) \
  102. LocalFree(hLocal)
  103. #define REALLOCATOR(hLocal, Size, Flags) \
  104. LocalReAlloc(hLocal, Size, Flags)
  105. #define MEMORYSIZER(hLocal) \
  106. LocalSize(hLocal)
  107. #else
  108. HLOCAL IEUnixLocalAlloc(UINT wFlags, UINT wBytes);
  109. HLOCAL IEUnixLocalReAlloc(HLOCAL hMemory, UINT wBytes, UINT wFlags);
  110. HLOCAL IEUnixLocalFree(HLOCAL hMem);
  111. UINT IEUnixLocalSize(HLOCAL hMem);
  112. LPVOID IEUnixLocalLock(HLOCAL hMem);
  113. #define ALLOCATOR(Flags, Size)\
  114. IEUnixLocalAlloc(Flags, Size)
  115. #define DEALLOCATOR(hLocal)\
  116. IEUnixLocalFree(hLocal)
  117. #define REALLOCATOR(hLocal, Size, Flags)\
  118. IEUnixLocalReAlloc(hLocal, Size, Flags)
  119. #define MEMORYSIZER(hLocal) \
  120. IEUnixLocalSize(hLocal)
  121. #endif /* unix */
  122. #endif // USE_PRIVATE_HEAP_IN_RETAIL
  123. #define INITIALIZE_DEBUG_MEMORY() \
  124. /* NOTHING */
  125. #define TERMINATE_DEBUG_MEMORY(bReport) \
  126. /* NOTHING */
  127. #define CHECK_MEMORY_FREED(bReport) \
  128. /* NOTHING */
  129. #define REPORT_DEBUG_MEMORY(bTermSym, bCloseFile) \
  130. /* NOTHING */
  131. #endif // defined(USE_DEBUG_MEMORY)
  132. #define ALLOCATE_ZERO_MEMORY(Size) \
  133. ALLOCATE_MEMORY(LPTR, (Size))
  134. #define ALLOCATE_FIXED_MEMORY(Size) \
  135. ALLOCATE_MEMORY(LMEM_FIXED, (Size))
  136. #define ALLOCATE_MEMORY(Flags, Size) \
  137. ALLOCATOR((UINT)(Flags), (UINT)(Size))
  138. #define FREE_ZERO_MEMORY(hLocal) \
  139. FREE_MEMORY((HLOCAL)(hLocal))
  140. #define FREE_FIXED_MEMORY(hLocal) \
  141. FREE_MEMORY((HLOCAL)(hLocal))
  142. #define FREE_MEMORY(hLocal) \
  143. DEALLOCATOR((HLOCAL)(hLocal))
  144. #define REALLOCATE_MEMORY(hLocal, Size, Flags) \
  145. REALLOCATOR((HLOCAL)(hLocal), (UINT)(Size), (UINT)(Flags))
  146. #define MEMORY_SIZE(hLocal) \
  147. MEMORYSIZER((HLOCAL)(hLocal))
  148. #if defined(__cplusplus)
  149. }
  150. #endif
  151. //
  152. // Wininet no longer uses moveable memory
  153. //
  154. #define LOCK_MEMORY(p) (LPSTR)(p)
  155. #define UNLOCK_MEMORY(p)