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.

108 lines
3.5 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /*
  5. heapDefs.h - include file for the storage allocator.
  6. */
  7. #if 0
  8. Storage allocation
  9. NULL
  10. |
  11. | pHeapFirst
  12. | ________________
  13. | |_____cw________| hh
  14. | | block | *Fgr <----------------------\
  15. | | of | |
  16. | | words | |
  17. | |_______________| |
  18. phhFree---->______cw______| hh |
  19. |--|------phhNext____| |
  20. | |____phhPrev--------------| |
  21. | | | | |
  22. | | | | |
  23. | | | | |
  24. | | block | | |
  25. | | of | | |
  26. | | words | | |
  27. | |_______________| | |
  28. | |_____cw________| | |
  29. | | . | *Fgr<---|-------------------|-\
  30. | |---------------| | | |
  31. | |_____cw________|<--------/ | |
  32. |-----phhNext_____| | |
  33. | phhPrev---------| | |
  34. | | | | |
  35. | | NULL | |
  36. |_______________| | |
  37. |___shake_word__| (if needed) <-----phhMac | |
  38. rgfgr--->|_____________--|-----------------------------/ |
  39. pfgrFree->|___________----|--\ |
  40. |_____________--|--|----------------------------/
  41. /--|--_____________|<-/
  42. \->|_____________--|-->NULL
  43. rgfgr can be indexed as an array with ifgrMac elements.
  44. The finger table slots are each one word in size.
  45. Putting the finger table at the high end of memory relies on the coding of
  46. of the CompactHeap routine; it moves the allocated blocks to low memory.
  47. The free list is threaded with addresses, NOT indexes.
  48. cw for a hunk includes size of header
  49. cw for a free hunk is negative the size of the hunk
  50. pfgr user's pointer to finger
  51. fgr pointer to hunk of whatever
  52. phh pointer to hunk header
  53. phhPrevs move toward the bottom of the free list
  54. phhNexts move toward the top
  55. phhFree should always have a phhNext of NULL (i.e. the list is just double,
  56. not circular).
  57. _________________
  58. |______cw_______|
  59. pph -----> ph ----------->| . |
  60. (FGR *) (FGR) | . |
  61. | . |
  62. |_______________|
  63. _________________
  64. phh ----->|______cw_______|
  65. |___phhNext_____|
  66. |___phhPrev_____|
  67. | . |
  68. | . |
  69. | . |
  70. |_______________|
  71. #endif
  72. typedef int *FGR; /* definitions for finger-related stuff. */
  73. typedef int **PFGR;
  74. /* storage allocator related stuff */
  75. struct _HH
  76. {
  77. int cw;
  78. struct _HH *phhNext;
  79. struct _HH *phhPrev;
  80. };
  81. typedef struct _HH HH;
  82. #ifdef OURHEAP
  83. /* MACROS */
  84. #define CwOfPfgr(pFgr) (*(*(pFgr) + bhh))
  85. #define CwOfPhh(phh) ((phh)->cw)
  86. #ifdef DEBUG
  87. #define fPointsFgrTbl(pfgr) (((FGR *)(pfgr) >= rgfgr) && ((FGR *)(pfgr) < pfgrMac))
  88. #endif
  89. FGR *PfgrAllocate();
  90. FGR *PfgrCopy();
  91. extern ENV envMem;
  92. #define cwof(i) ((sizeof(i)+sizeof(int)-1)/sizeof(int))
  93. #endif /* OURHEAP */
  94.