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.

195 lines
5.1 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Memory Management
  6. File: Memchk.cpp
  7. Owner: PramodD
  8. TODO: restore the IIS5 debug heap wrappers
  9. This is the Memory Manager source file
  10. ===================================================================*/
  11. #include "denpre.h"
  12. #pragma hdrstop
  13. #include "perfdata.h"
  14. #include "memchk.h"
  15. HANDLE g_hDenaliHeap = NULL;
  16. /*===================================================================
  17. int ::DenaliMemIsValid
  18. Global function which validates an allocated memory pointer
  19. Parameters:
  20. NONE
  21. Returns:
  22. 1 Valid pointer
  23. 0 Invalid pointer
  24. ===================================================================*/
  25. int DenaliMemIsValid( void * pvIn )
  26. {
  27. return 1;
  28. }
  29. /*===================================================================
  30. ::DenaliMemInit
  31. Initializes the memory manager
  32. Parameters:
  33. const char * szFile Source file in which this was called
  34. int lineno The line number in the source file
  35. Returns:
  36. S_OK on success
  37. ===================================================================*/
  38. HRESULT DenaliMemInit( const char *szFile, int lineno )
  39. {
  40. g_hDenaliHeap = ::HeapCreate( 0, 0, 0 );
  41. return g_hDenaliHeap ? S_OK : E_OUTOFMEMORY;
  42. }
  43. /*===================================================================
  44. void ::DenaliMemUnInit
  45. Uninitializes the memory manager
  46. Parameters:
  47. const char * szFile Source file in which this was called
  48. int lineno The line number in the source file
  49. Returns:
  50. NONE
  51. ===================================================================*/
  52. void DenaliMemUnInit( const char *szFile, int lineno )
  53. {
  54. if (g_hDenaliHeap)
  55. {
  56. ::HeapDestroy(g_hDenaliHeap);
  57. g_hDenaliHeap = NULL;
  58. }
  59. }
  60. /*===================================================================
  61. void ::DenaliLogCall
  62. Writes source file and line number for log message to log file
  63. Parameters:
  64. const char * szLog Log message
  65. const char * szFile Source file in which this was called
  66. int lineno The line number in the source file
  67. Returns:
  68. NONE
  69. ===================================================================*/
  70. void DenaliLogCall( const char * szLog, const char *szFile, int lineno )
  71. {
  72. return;
  73. }
  74. /*===================================================================
  75. void ::DenaliMemDiagnostics
  76. Diagnostics for the memory manager
  77. Parameters:
  78. const char * szFile Source file in which this was called
  79. int lineno The line number in the source file
  80. Returns:
  81. NONE
  82. ===================================================================*/
  83. void DenaliMemDiagnostics( const char *szFile, int lineno )
  84. {
  85. return;
  86. }
  87. /*===================================================================
  88. void * ::DenaliMemAlloc
  89. Allocates a block of memory.
  90. Parameters:
  91. size_t cSize Size in bytes to be allocated
  92. const char * szFile Source file in which function is called
  93. int lineno Line number at which function is called
  94. Returns:
  95. NONE
  96. ===================================================================*/
  97. void * DenaliMemAlloc( size_t cSize, const char *szFile, int lineno )
  98. {
  99. return ::HeapAlloc( g_hDenaliHeap, 0, cSize );
  100. }
  101. /*===================================================================
  102. void ::DenaliMemFree
  103. Validates and frees a block of allocated memory.
  104. Parameters:
  105. BYTE * pIn Pointer to free
  106. const char * szFile Source file in which function is called
  107. int lineno Line number at which function is called
  108. Returns:
  109. NONE
  110. ===================================================================*/
  111. void DenaliMemFree( void * pIn, const char *szFile, int lineno )
  112. {
  113. ::HeapFree( g_hDenaliHeap, 0, pIn );
  114. }
  115. /*===================================================================
  116. void * ::DenaliMemCalloc
  117. Allocates and clears a block of memory.
  118. Parameters:
  119. size_t cNum Number of elements to be allocated
  120. size_t cbSize Size in bytes of each element
  121. const char * szFile Source file in which function is called
  122. int lineno Line number at which function is called
  123. Returns:
  124. NONE
  125. ===================================================================*/
  126. void * DenaliMemCalloc(size_t cNum, size_t cbSize,
  127. const char *szFile, int lineno )
  128. {
  129. return ::HeapAlloc( g_hDenaliHeap, HEAP_ZERO_MEMORY, cNum * cbSize );
  130. }
  131. /*===================================================================
  132. void ::DenaliMemReAlloc
  133. Validates and frees a block of allocated memory.
  134. Parameters:
  135. BYTE * pIn Pointer memory to ReAllocate
  136. size_t cSize Number of bytes to allocate
  137. const char * szFile Source file in which function is called
  138. int lineno Line number at which function is called
  139. Returns:
  140. Pointer to allocated block
  141. ===================================================================*/
  142. void * DenaliMemReAlloc( void * pIn, size_t cSize, const char *szFile, int lineno )
  143. {
  144. return ::HeapReAlloc( g_hDenaliHeap, 0, pIn, cSize );
  145. }