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.

165 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. poolmem.h
  5. Abstract:
  6. Declares the pool memory interface. A pool of memory is a set of
  7. blocks (typically 8K each) that are used for several allocations,
  8. and then freed at the end of processing. See below for routines.
  9. Author:
  10. Marc R. Whitten (marcw) 02-Feb-1997
  11. Revision History:
  12. jimschm 04-Feb-1998 Named pools for tracking
  13. --*/
  14. #pragma once
  15. typedef PVOID POOLHANDLE;
  16. /*++
  17. Create and destroy routines:
  18. POOLHANDLE
  19. PoolMemInitPool (
  20. VOID
  21. );
  22. POOLHANDLE
  23. PoolMemInitNamedPool (
  24. IN PCSTR Name
  25. );
  26. VOID
  27. PoolMemDestroyPool (
  28. IN POOLHANDLE Handle
  29. );
  30. Primitive routines:
  31. PVOID
  32. PoolMemGetMemory (
  33. IN POOLHANDLE Handle,
  34. IN DWORD Size
  35. );
  36. PVOID
  37. PoolMemGetAlignedMemory (
  38. IN POOLHANDLE Handle,
  39. IN DWORD Size
  40. );
  41. VOID
  42. PoolMemReleaseMemory (
  43. IN POOLHANDLE Handle,
  44. IN PVOID Memory
  45. );
  46. Performance and debugging control:
  47. VOID
  48. PoolMemSetMinimumGrowthSize (
  49. IN POOLHANDLE Handle,
  50. IN DWORD GrowthSize
  51. );
  52. VOID
  53. PoolMemEmptyPool (
  54. IN POOLHANDLE Handle
  55. );
  56. VOID
  57. PoolMemDisableTracking (
  58. IN POOLHANDLE Handle
  59. );
  60. Allocation and duplication of data types:
  61. PCTSTR
  62. PoolMemCreateString (
  63. IN POOLHANDLE Handle,
  64. IN UINT TcharCount
  65. );
  66. PCTSTR
  67. PoolMemCreateDword (
  68. IN POOLHANDLE Handle
  69. );
  70. PBYTE
  71. PoolMemDuplicateMemory (
  72. IN POOLHANDLE Handle,
  73. IN PBYTE Data,
  74. IN UINT DataSize
  75. );
  76. PDWORD
  77. PoolMemDuplciateDword (
  78. IN POOLHANDLE Handle,
  79. IN DWORD Data
  80. );
  81. PTSTR
  82. PoolMemDuplicateString (
  83. IN POOLHANDLE Handle,
  84. IN PCTSTR String
  85. );
  86. PTSTR
  87. PoolMemDuplicateMultiSz (
  88. IN POOLHANDLE Handle,
  89. IN PCTSTR MultiSz
  90. );
  91. --*/
  92. #define ByteCountW(x) (lstrlen(x)*sizeof(WCHAR))
  93. //
  94. // Default size of memory pool blocks. This can be changed on a per-pool basis
  95. // by calling PoolMemSetMinimumGrowthSize().
  96. //
  97. #define POOLMEMORYBLOCKSIZE 8192
  98. POOLHANDLE
  99. PoolMemInitPool (
  100. VOID
  101. );
  102. #define PoolMemInitNamedPool(x) PoolMemInitPool()
  103. VOID
  104. PoolMemDestroyPool (
  105. IN POOLHANDLE Handle
  106. );
  107. //
  108. // Callers should use PoolMemGetMemory or PoolMemGetAlignedMemory. These each decay into
  109. // PoolMemRealGetMemory.
  110. //
  111. #define PoolMemGetMemory(h,s) PoolMemRealGetMemory(h,s,0)
  112. #define PoolMemGetAlignedMemory(h,s) PoolMemRealGetMemory(h,s,sizeof(DWORD))
  113. PVOID PoolMemRealGetMemory(IN POOLHANDLE Handle, IN DWORD Size, IN DWORD AlignSize);
  114. VOID PoolMemReleaseMemory (IN POOLHANDLE Handle, IN PVOID Memory);
  115. VOID PoolMemSetMinimumGrowthSize(IN POOLHANDLE Handle, IN DWORD Size);