Leaked source code of windows server 2003
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.

62 lines
1.9 KiB

  1. #ifndef _SMAPIMEM_H_
  2. #define _SMAPIMEM_H_
  3. // Buffer link overhead.
  4. // Blocks of memory obtained with MAPIAllocateMore are linked to a
  5. // block obtained with MAPIAllocateBuffer, so that the whole chain
  6. // may be freed with one call to MAPIFreeBuffer.
  7. typedef struct _BufInternal * LPBufInternal;
  8. typedef struct _BufInternal
  9. {
  10. ULONG ulAllocFlags;
  11. LPBufInternal pLink;
  12. } BufInternal;
  13. // Values for ulAllocFlags. This dword contains two kinds of
  14. // information:
  15. // = In the high-order word, flags telling whether or not
  16. // the block is the head of an allocation chain, and whether
  17. // the block contains additional debugging information.
  18. // = In the low-order word, an enum telling which heap
  19. // it was allocated from.
  20. #define ALLOC_WITH_ALLOC ((ULONG) 0x10000000)
  21. #define ALLOC_WITH_ALLOC_MORE ((ULONG) 0x20000000)
  22. #define FLAGSMASK ((ULONG) 0xFFFF0000)
  23. #define GetFlags(_fl) ((ULONG) (_fl) & FLAGSMASK)
  24. // Conversion macros
  25. #define INT_SIZE(a) ((a) + sizeof(BufInternal))
  26. #define LPBufExtFromLPBufInt(PBUFINT) \
  27. ((LPVOID)(((LPBYTE)PBUFINT) + sizeof(BufInternal)))
  28. #define LPBufIntFromLPBufExt(PBUFEXT) \
  29. ((LPBufInternal)(((LPBYTE)PBUFEXT) - sizeof(BufInternal)))
  30. #ifdef DEBUG
  31. #define TellBadBlock(_p, _s) \
  32. { DOUT("MAPIAlloc: memory block [%#08lx] %s", _p, _s); \
  33. AssertSz(0, "Bad memory block"); }
  34. #define TellBadBlockInt(_p, _s) \
  35. { DOUT("MAPIAlloc: memory block [%#08lx] %s", LPBufExtFromLPBufInt(_p), _s); \
  36. AssertSz(0, "Bad memory block"); }
  37. BOOL FValidAllocChain(LPBufInternal lpBuf);
  38. #else
  39. #define TellBadBlock(_p, _s)
  40. #define TellBadBlockInt(_p, _s)
  41. #endif // DEBUG
  42. SCODE SMAPIAllocateBuffer(ULONG ulSize, LPVOID * lppv);
  43. SCODE SMAPIAllocateMore(ULONG ulSize, LPVOID lpv, LPVOID * lppv);
  44. #endif // _SMAPIMEM_H_