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.

86 lines
3.0 KiB

  1. #ifndef _INC_MEM
  2. #define _INC_MEM
  3. #ifdef WIN32
  4. //
  5. // These macros are used in our controls, that in 32 bits we simply call
  6. // LocalAlloc as to have the memory associated with the process that created
  7. // it and as such will be cleaned up if the process goes away.
  8. //
  9. #ifdef DEBUG
  10. LPVOID PUBLIC MemAlloc(HANDLE hheap, DWORD cb);
  11. LPVOID PUBLIC MemReAlloc(HANDLE hheap, LPVOID pb, DWORD cb);
  12. BOOL PUBLIC MemFree(HANDLE hheap, LPVOID pb);
  13. DWORD PUBLIC MemSize(HANDLE hheap, LPVOID pb);
  14. #else // DEBUG
  15. #define MemAlloc(hheap, cb) HeapAlloc((hheap), HEAP_ZERO_MEMORY, (cb))
  16. #define MemReAlloc(hheap, pb, cb) HeapReAlloc((hheap), HEAP_ZERO_MEMORY, (pb),(cb))
  17. #define MemFree(hheap, pb) HeapFree((hheap), 0, (pb))
  18. #define MemSize(hheap, pb) HeapSize((hheap), 0, (LPCVOID)(pb))
  19. #endif // DEBUG
  20. #else // WIN32
  21. // In 16 bit code we need the Allocs to go from our heap code as we do not
  22. // want to limit them to 64K of data. If we have some type of notification of
  23. // 16 bit application termination, We may want to see if we can
  24. // dedicate different heaps for different processes to cleanup...
  25. #define MemAlloc(hheap, cb) Alloc(cb) /* calls to verify heap exists */
  26. #define MemReAlloc(hheap, pb, cb) ReAlloc(pb, cb)
  27. #define MemFree(hheap, pb) Free(pb)
  28. #define MemSize(hheap, pb) GetSize((LPCVOID)pb)
  29. #endif // WIN32
  30. void PUBLIC Mem_Terminate();
  31. extern HANDLE g_hSharedHeap;
  32. // Shared memory allocation functions.
  33. //
  34. // void _huge* SharedAlloc(long cb);
  35. // Alloc a chunk of memory, quickly, with no 64k limit on size of
  36. // individual objects or total object size. Initialize to zero.
  37. //
  38. void _huge* PUBLIC SharedAlloc(long cb);
  39. // void _huge* SharedReAlloc(void _huge* pb, long cb);
  40. // Realloc one of above. If pb is NULL, then this function will do
  41. // an alloc for you. Initializes new portion to zero.
  42. //
  43. void _huge* PUBLIC SharedReAlloc(void _huge* pb, long cb);
  44. // BOOL SharedFree(void _huge* FAR * ppb);
  45. // Free a chunk of memory alloced or realloced with above routines.
  46. // Sets *ppb to zero.
  47. //
  48. BOOL PUBLIC SharedFree(void _huge* * ppb);
  49. // DWORD SharedGetSize(void _huge* pb);
  50. // Get the size of a block allocated by Alloc()
  51. //
  52. DWORD PUBLIC SharedGetSize(void _huge* pb);
  53. // type _huge * SharedAllocType(type); (macro)
  54. // Alloc some memory the size of <type> and return pointer to <type>.
  55. //
  56. #define SharedAllocType(type) (type _huge *)SharedAlloc(sizeof(type))
  57. // type _huge * SharedAllocArray(type, int cNum); (macro)
  58. // Alloc an array of data the size of <type>.
  59. //
  60. #define SharedAllocArray(type, cNum) (type _huge *)SharedAlloc(sizeof(type) * (cNum))
  61. // type _huge * SharedReAllocArray(type, void _huge * pb, int cNum);
  62. //
  63. #define SharedReAllocArray(type, pb, cNum) (type _huge *)SharedReAlloc(pb, sizeof(type) * (cNum))
  64. #endif // !_INC_MEM