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.

83 lines
2.1 KiB

  1. /*****************************************************************************\
  2. * MODULE: mem.h
  3. *
  4. * Header file for memory handling routines (mem.cxx).
  5. *
  6. *
  7. * Copyright (C) 1996-1998 Microsoft Corporation.
  8. * Copyright (C) 1996-1998 Hewlett Packard Company.
  9. *
  10. * History:
  11. * 07-Oct-1996 HWP-Guys Initiated port from win95 to winNT
  12. *
  13. \*****************************************************************************/
  14. /*-----------------------------------*\
  15. | Constants
  16. \*-----------------------------------*/
  17. #define DEADBEEF 0xdeadbeef // Tail Marker.
  18. #define MAPMEM ((HANDLE)-1) // File-Map-Memory.
  19. #define MEM_HEADSIZE (4 * sizeof(DWORD)) //
  20. #define MEM_TAILSIZE (1 * sizeof(DWORD)) //
  21. #define MEM_SIZE (MEM_HEADSIZE + MEM_TAILSIZE) //
  22. /*-----------------------------------*\
  23. | MEMHEAD Structure
  24. \*-----------------------------------*/
  25. typedef struct _MEMHEAD {
  26. struct _MEMHEAD *pmPrev; // Reference to previous mem-block (dbg-only).
  27. struct _MEMHEAD *pmNext; // Reference to next mem-block (dbg-only).
  28. DWORD dwTag; // Memory Tag.
  29. DWORD cbSize; // size of block allocated (non-aligned size).
  30. PVOID pvMem[1]; // Start of user-addressable memory.
  31. } MEMHEAD;
  32. typedef MEMHEAD *PMEMHEAD;
  33. typedef MEMHEAD NEAR *NPMEMHEAD;
  34. typedef MEMHEAD FAR *LPMEMHEAD;
  35. /*-----------------------------------*\
  36. | MEMTAIL Structure
  37. \*-----------------------------------*/
  38. typedef struct _MEMTAIL {
  39. DWORD dwSignature;
  40. } MEMTAIL;
  41. typedef MEMTAIL *PMEMTAIL;
  42. typedef MEMTAIL NEAR *NPMEMTAIL;
  43. typedef MEMTAIL FAR *LPMEMTAIL;
  44. /*-----------------------------------*\
  45. | memAlignSize
  46. \*-----------------------------------*/
  47. _inline BOOL memAlignSize(
  48. DWORD cbSize)
  49. {
  50. return ((cbSize & 3) ? (cbSize + (sizeof(DWORD) - (cbSize & 3))) : cbSize);
  51. }
  52. PVOID memAlloc(
  53. UINT cbSize);
  54. BOOL memFree(
  55. PVOID pMem,
  56. UINT cbSize);
  57. UINT memGetSize(
  58. PVOID pMem);
  59. VOID memCopy(
  60. PSTR *ppDst,
  61. PSTR pSrc,
  62. UINT cbSize,
  63. PSTR *ppBuf);
  64. PTSTR memAllocStr(
  65. LPCTSTR lpszStr);
  66. BOOL memFreeStr(
  67. PTSTR lpszStr);