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.

101 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. Alloc.cpp
  5. Abstract:
  6. Custom heap allocator
  7. Author:
  8. George V. Reilly (GeorgeRe) Oct-1999
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. Internet Information Server RunTime Library
  13. Revision History:
  14. 10/11/1999 - Initial
  15. --*/
  16. #include "precomp.hxx"
  17. #include "alloc.h"
  18. #include <irtldbg.h>
  19. // Private heap for IIS
  20. HANDLE g_hHeap = NULL;
  21. BOOL
  22. WINAPI
  23. IisHeapInitialize()
  24. {
  25. g_hHeap = ::HeapCreate(0, 0, 0);
  26. return (g_hHeap != NULL);
  27. }
  28. VOID
  29. WINAPI
  30. IisHeapTerminate()
  31. {
  32. if (g_hHeap)
  33. {
  34. IRTLVERIFY(::HeapDestroy(g_hHeap));
  35. g_hHeap = NULL;
  36. }
  37. }
  38. // Private IIS heap
  39. HANDLE
  40. WINAPI
  41. IisHeap()
  42. {
  43. IRTLASSERT(g_hHeap != NULL);
  44. return g_hHeap;
  45. }
  46. // Allocate dwBytes
  47. LPVOID
  48. WINAPI
  49. IisMalloc(
  50. IN SIZE_T dwBytes)
  51. {
  52. IRTLASSERT(g_hHeap != NULL);
  53. return ::HeapAlloc( g_hHeap, 0, dwBytes );
  54. }
  55. // Allocate dwBytes. Memory is zeroed
  56. LPVOID
  57. WINAPI
  58. IisCalloc(
  59. IN SIZE_T dwBytes)
  60. {
  61. IRTLASSERT(g_hHeap != NULL);
  62. return ::HeapAlloc( g_hHeap, HEAP_ZERO_MEMORY, dwBytes );
  63. }
  64. // Reallocate lpMem to dwBytes
  65. LPVOID
  66. WINAPI
  67. IisReAlloc(
  68. IN LPVOID lpMem,
  69. IN SIZE_T dwBytes)
  70. {
  71. IRTLASSERT(g_hHeap != NULL);
  72. return ::HeapReAlloc( g_hHeap, 0, lpMem, dwBytes);
  73. }
  74. // Free lpMem
  75. BOOL
  76. WINAPI
  77. IisFree(
  78. IN LPVOID lpMem)
  79. {
  80. IRTLASSERT(g_hHeap != NULL);
  81. return ::HeapFree( g_hHeap, 0, lpMem );
  82. }