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.

70 lines
2.5 KiB

  1. /*
  2. * memmgr.h
  3. *
  4. * Copyright (c) 1998 by Microsoft Corporation, Redmond, WA
  5. *
  6. * Abstract:
  7. * This is the header file for the T.120 memory allocation mechanism. This
  8. * file contains the declarations necessary to allocate and distribute memory
  9. * in the form of Memory objects within T.120.
  10. *
  11. * This implementation defines priorities of memory allocations. A lower
  12. * priority number implies higher priority. Priority-0 allocations will be
  13. * satisfied, unless the system is out of memory. Priorities 1 and 2
  14. * limit the amount of total memory that can be allocated, but priority 1 (recv priority)
  15. * has higher water mark limits than priority 2 (send priority).
  16. *
  17. * Protected Member Functions:
  18. * None.
  19. *
  20. * Caveats:
  21. * None.
  22. *
  23. * Author:
  24. * Christos Tsollis
  25. */
  26. /*
  27. * We define the following 3 memory priorities:
  28. * TOP_PRIORITY (0): The allocation will succeed unless the system is out of memory
  29. * RECV_PRIORITY (1): Allocation will succeed only if less than 1 MB has been allocated
  30. * SEND_PRIORITY (2): Allocation will succeed only if less than 0xE0000 bytes have been allocated so far.
  31. */
  32. #ifndef _T120_MEMORY_MANAGER
  33. #define _T120_MEMORY_MANAGER
  34. #include "memory.h"
  35. // This is the main T.120 allocation routine
  36. PMemory AllocateMemory (
  37. PUChar reference_ptr,
  38. UINT length,
  39. MemoryPriority priority = HIGHEST_PRIORITY);
  40. // Routine to ReAlloc memory allocated by AllocateMemory().
  41. BOOL ReAllocateMemory (
  42. PMemory *pmemory,
  43. UINT length);
  44. // Routine to free the memory allocated by AllocateMemory().
  45. void FreeMemory (PMemory memory);
  46. // To discover how much space is available at a non-TOP priority...
  47. unsigned int GetFreeMemory (MemoryPriority priority);
  48. // Macro to get to the Memory object from app-requested buffer space
  49. #define GetMemoryObject(p) ((PMemory) ((PUChar) p - (sizeof(Memory) + MAXIMUM_PROTOCOL_OVERHEAD)))
  50. // Macro to get to the Memory object from the coder-alloced buffer space
  51. #define GetMemoryObjectFromEncData(p) ((PMemory) ((PUChar) p - sizeof(Memory)))
  52. // Routines to lock/unlock (AddRef/Release) memory allocated by AllocateMemory()
  53. #define LockMemory(memory) ((memory)->Lock())
  54. #define UnlockMemory(memory) (FreeMemory(memory))
  55. // Routines to allocate, realloc and free space without an associated Memory object
  56. #ifdef DEBUG
  57. PUChar Allocate (UINT length);
  58. #else
  59. # define Allocate(length) ((PUChar) new BYTE[length])
  60. #endif // DEBUG
  61. #define Free(p) (delete [] (BYTE *) (p))
  62. #endif // _T120_MEMORY_MANAGER