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.

90 lines
2.2 KiB

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