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.

240 lines
4.6 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. #ifdef WINHTTP_FOR_MSXML
  14. #error include msxmlmem.h, not debugmem.h, for MSXML
  15. #endif
  16. #if defined(__cplusplus)
  17. extern "C" {
  18. #endif
  19. //
  20. // manifests
  21. //
  22. //
  23. // USE_PRIVATE_HEAP_IN_RETAIL - by default we use the process heap in the retail
  24. // build. Alternative is to use a private (wininet) heap (which we do in the
  25. // debug version if required)
  26. //
  27. #if !defined(USE_PRIVATE_HEAP_IN_RETAIL)
  28. #define USE_PRIVATE_HEAP_IN_RETAIL 0
  29. #endif
  30. //
  31. // prototypes
  32. //
  33. VOID
  34. InternetDebugMemInitialize(
  35. VOID
  36. );
  37. VOID
  38. InternetDebugMemTerminate(
  39. IN BOOL bReport
  40. );
  41. HLOCAL
  42. InternetDebugAllocMem(
  43. IN UINT Flags,
  44. IN UINT Size,
  45. IN LPSTR File,
  46. IN DWORD Line
  47. );
  48. HLOCAL
  49. InternetDebugFreeMem(
  50. IN HLOCAL hLocal,
  51. IN LPSTR File,
  52. IN DWORD Line
  53. );
  54. HLOCAL
  55. InternetDebugReAllocMem(
  56. IN HLOCAL hLocal,
  57. IN UINT Size,
  58. IN UINT Flags,
  59. IN LPSTR File,
  60. IN DWORD Line
  61. );
  62. SIZE_T
  63. InternetDebugSizeMem(
  64. IN HLOCAL hLocal,
  65. IN LPSTR File,
  66. IN DWORD Line
  67. );
  68. BOOL
  69. InternetDebugCheckMemFreed(
  70. IN BOOL bReport
  71. );
  72. BOOL
  73. InternetDebugMemReport(
  74. IN BOOL bTerminateSymbols,
  75. IN BOOL bCloseFile
  76. );
  77. //
  78. // macros
  79. //
  80. #if defined(USE_DEBUG_MEMORY)
  81. #define ALLOCATOR(Flags, Size) \
  82. InternetDebugAllocMem(Flags, Size, __FILE__, __LINE__)
  83. #define DEALLOCATOR(hLocal) \
  84. InternetDebugFreeMem(hLocal, __FILE__, __LINE__)
  85. #define REALLOCATOR(hLocal, Size, Flags) \
  86. InternetDebugReAllocMem(hLocal, Size, Flags, __FILE__, __LINE__)
  87. #define MEMORYSIZER(hLocal) \
  88. InternetDebugSizeMem(hLocal, __FILE__, __LINE__)
  89. #define INITIALIZE_MEMORY_MANAGER() \
  90. InternetDebugMemInitialize()
  91. #define TERMINATE_MEMORY_MANAGER(bReport) \
  92. InternetDebugMemTerminate(bReport)
  93. #define CHECK_MEMORY_FREED(bReport) \
  94. InternetDebugCheckMemFreed(bReport)
  95. #define REPORT_DEBUG_MEMORY(bTermSym, bCloseFile) \
  96. InternetDebugMemReport(bTermSym, bCloseFile)
  97. #else // retail version
  98. #if defined(USE_ROCKALL)
  99. extern void INITIALIZE_MEMORY_MANAGER();
  100. extern void TERMINATE_MEMORY_MANAGER(BOOL bReport);
  101. extern void* ALLOCATOR(int Flags, int Size);
  102. extern void* DEALLOCATOR(void *hLocal);
  103. extern void* REALLOCATOR(void *hLocal, int Size, int Flags);
  104. extern int MEMORYSIZER(void *hLocal);
  105. #else
  106. #define ALLOCATOR(Flags, Size) \
  107. LocalAlloc(Flags, Size)
  108. #define DEALLOCATOR(hLocal) \
  109. LocalFree(hLocal)
  110. #define REALLOCATOR(hLocal, Size, Flags) \
  111. LocalReAlloc(hLocal, Size, Flags)
  112. #define MEMORYSIZER(hLocal) \
  113. LocalSize(hLocal)
  114. #define INITIALIZE_MEMORY_MANAGER() \
  115. /* NOTHING */
  116. #define TERMINATE_MEMORY_MANAGER(bReport) \
  117. /* NOTHING */
  118. #endif
  119. #define CHECK_MEMORY_FREED(bReport) \
  120. /* NOTHING */
  121. #define REPORT_DEBUG_MEMORY(bTermSym, bCloseFile) \
  122. /* NOTHING */
  123. #endif // defined(USE_DEBUG_MEMORY)
  124. #if defined(USE_ROCKALL)
  125. #define ALLOCATE_ZERO_MEMORY(Size) \
  126. ALLOCATE_MEMORY(LPTR, (Size))
  127. #define ALLOCATE_FIXED_MEMORY(Size) \
  128. ALLOCATE_MEMORY(LMEM_FIXED, (Size))
  129. #define ALLOCATE_MEMORY(Flags, Size) \
  130. ALLOCATOR((UINT)(Flags), (UINT)(Size))
  131. #define FREE_ZERO_MEMORY(hLocal) \
  132. FREE_MEMORY((void*)(hLocal))
  133. #define FREE_FIXED_MEMORY(hLocal) \
  134. FREE_MEMORY((void*)(hLocal))
  135. #define FREE_MEMORY(hLocal) \
  136. DEALLOCATOR((void*)(hLocal))
  137. #define REALLOCATE_MEMORY(hLocal, Size, Flags) \
  138. REALLOCATOR((void*)(hLocal), (UINT)(Size), (UINT)(Flags))
  139. #define MEMORY_SIZE(hLocal) \
  140. MEMORYSIZER((void*)(hLocal))
  141. #else
  142. #define ALLOCATE_ZERO_MEMORY(Size) \
  143. ALLOCATE_MEMORY(LPTR, (Size))
  144. #define ALLOCATE_FIXED_MEMORY(Size) \
  145. ALLOCATE_MEMORY(LMEM_FIXED, (Size))
  146. #define ALLOCATE_MEMORY(Flags, Size) \
  147. ALLOCATOR((UINT)(Flags), (UINT)(Size))
  148. #define FREE_ZERO_MEMORY(hLocal) \
  149. FREE_MEMORY((HLOCAL)(hLocal))
  150. #define FREE_FIXED_MEMORY(hLocal) \
  151. FREE_MEMORY((HLOCAL)(hLocal))
  152. #define FREE_MEMORY(hLocal) \
  153. DEALLOCATOR((HLOCAL)(hLocal))
  154. #define REALLOCATE_MEMORY(hLocal, Size, Flags) \
  155. REALLOCATOR((HLOCAL)(hLocal), (UINT)(Size), (UINT)(Flags))
  156. #define MEMORY_SIZE(hLocal) \
  157. MEMORYSIZER((HLOCAL)(hLocal))
  158. #endif // USE_ROCKALL
  159. #define New new
  160. #if defined(__cplusplus)
  161. }
  162. #endif
  163. //
  164. // Wininet no longer uses moveable memory
  165. //
  166. #define LOCK_MEMORY(p) (LPSTR)(p)
  167. #define UNLOCK_MEMORY(p)