Changeset 4164 for trunk/src/win32k/misc/smalloc_avl.c
- Timestamp:
- Sep 2, 2000, 11:08:23 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/misc/smalloc_avl.c
r2511 r4164 1 /* $Id: smalloc_avl.c,v 1. 3 2000-01-24 18:19:00bird Exp $1 /* $Id: smalloc_avl.c,v 1.4 2000-09-02 21:08:15 bird Exp $ 2 2 * 3 3 * Swappable Heap - AVL. … … 59 59 ******************************************************************************/ 60 60 #include <os2.h> 61 #include "devSegDf.h" /* Win32k segment definitions. */ 61 62 #ifdef RING0 62 63 #include "dev32hlp.h" … … 140 141 static PHEAPANCHOR phaFirst; /* Pointer to the first anchor block.*/ 141 142 static PHEAPANCHOR phaLast; /* Pointer to the last anchor block.*/ 142 static unsignedcbSwpHeapMax; /* Maximum amount of memory used by the heap. */143 static PMEMBLOCKCHUNK pmcFirst; 143 unsigned cbSwpHeapMax; /* Maximum amount of memory used by the heap. */ 144 static PMEMBLOCKCHUNK pmcFirst; /* Pointer to the first memblock chunk. */ 144 145 145 146 #ifndef RING0 … … 1066 1067 1067 1068 return cb; 1069 } 1070 1071 1072 /** 1073 * Get amount of used memory (in bytes) 1074 * @returns Amount of used memory (in bytes). 1075 */ 1076 unsigned _swp_memused(void) 1077 { 1078 PHEAPANCHOR pha = phaFirst; 1079 unsigned cb; 1080 1081 #ifdef ALLWAYS_HEAPCHECK 1082 if (!_swp_heap_check()) 1083 kprintf(("_swp_memused: _swp_heap_check failed!\n")); 1084 #endif 1085 1086 for (cb = 0; pha != NULL; pha = pha->pNext) 1087 cb += pha->cbUsed; 1088 1089 return cb; 1090 } 1091 1092 1093 /** 1094 * Collects the heap state. 1095 * @returns 0 on success. 1096 * -1 on error. 1097 * @param pState Pointer to a HEAPSTATE structure which is 1098 * filled upon successful return. 1099 */ 1100 int _swp_state(PHEAPSTATE pState) 1101 { 1102 PHEAPANCHOR pha; 1103 1104 #ifdef ALLWAYS_HEAPCHECK 1105 if (!_res_heap_check()) 1106 { 1107 kprintf(("_res_state: _res_heap_check failed!\n")); 1108 return -1; 1109 } 1110 #endif 1111 1112 if (pState == NULL) 1113 return -1; 1114 1115 /* 1116 * Loop thru all the anchor blocks and all memory blocks 1117 * building the stats. 1118 */ 1119 memset(pState, 0, sizeof(HEAPSTATE)); 1120 for (pha = phaFirst; pha != NULL; pha = pha->pNext) 1121 { 1122 AVLENUMDATA EnumData; 1123 PAVLENUMDATA pEnumData = SSToDS(&EnumData); 1124 PMEMBLOCK pmb; 1125 1126 /* count of free blocks */ 1127 pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pcoreFree, pEnumData, TRUE); 1128 while (pmb) 1129 { 1130 pState->cBlocksFree++; 1131 pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData); 1132 } 1133 1134 /* count of used blocks */ 1135 pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pcoreUsed, pEnumData, TRUE); 1136 while (pmb) 1137 { 1138 pState->cBlocksUsed++; 1139 pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData); 1140 } 1141 1142 /* sizes */ 1143 pState->cbHeapSize += pha->cbSize; 1144 pState->cbHeapFree += pha->cbFree; 1145 pState->cbHeapUsed += pha->cbUsed; 1146 } 1147 1148 return 0; 1068 1149 } 1069 1150
Note:
See TracChangeset
for help on using the changeset viewer.