Changeset 2511 for trunk/src/win32k/misc/rmalloc_avl.c
- Timestamp:
- Jan 24, 2000, 7:19:01 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/misc/rmalloc_avl.c
r2508 r2511 1 /* $Id: rmalloc_avl.c,v 1. 4 2000-01-24 03:05:14bird Exp $1 /* $Id: rmalloc_avl.c,v 1.5 2000-01-24 18:19:00 bird Exp $ 2 2 * 3 3 * Resident Heap - AVL. … … 16 16 * Defined Constants And Macros * 17 17 *******************************************************************************/ 18 #pragma info(notrd) 18 19 #ifdef DEBUG 19 20 #define DEBUG_ALLOC 20 #define ALLWAYS_HEAPCHECK 21 #undef ALLWAYS_HEAPCHECK 22 #undef SOMETIMES_HEAPCHECK 21 23 #endif 22 24 … … 41 43 #endif 42 44 43 44 45 /****************************************************************************** 45 46 * Headerfiles … … 48 49 #ifdef RING0 49 50 #include "dev32hlp.h" 50 #include "asmutils.h"51 #else52 #include <builtin.h>53 #define Int3() __interrupt(3)54 51 #endif 52 #include "asmutils.h" 55 53 #include "log.h" 56 54 #include "rmalloc.h" 57 #include <memory.h>58 55 #include "dev32.h" 59 56 #include "avl.h" 60 57 #include "macros.h" 58 #include <memory.h> 61 59 62 60 … … 139 137 static PMEMBLOCK resFindUsedBlock(PHEAPANCHOR *ppha, void *pvUser); 140 138 static PMEMBLOCK resFindWithinUsedBlock(PHEAPANCHOR *ppha, void *pvUser); 139 #ifdef DEBUG_ALLOC 141 140 static int resCheckAVLTree(PMEMBLOCK pmb); 142 141 static int resCheckAVLTreeFree(PAVLNODECORE pNode); 142 #endif 143 143 static unsigned _res_dump_subheaps_callback(PMEMBLOCK pmb, PSUBHEAPS_CALLBACK_PARAM pCb); 144 144 static unsigned _res_dump_allocated_callback(PMEMBLOCK pmb, PALLOCATED_CALLBACK_PARAM pParam); … … 252 252 PMEMBLOCKFREE pmbfRightParent; 253 253 PMEMBLOCKFREE pmbfLeft; 254 PMEMBLOCKFREE pmbfTmp;255 254 256 255 pha->cbFree += pmb->cbSize; … … 592 591 resInsertFree(phaFirst, pmb); 593 592 594 #if def ALLWAYS_HEAPCHECK593 #if defined(ALLWAYS_HEAPCHECK) || defined(SOMETIMES_HEAPCHECK) 595 594 if (!_res_heap_check()) 596 595 { /* error! */ … … 602 601 } 603 602 #endif 604 #if def RING3605 f Inited = TRUE;603 #ifndef RING0 604 fResInited = TRUE; 606 605 #endif 607 606 return 0; … … 618 617 void * rmalloc(unsigned cbSize) 619 618 { 620 #if def ALLWAYS_HEAPCHECK619 #if defined(ALLWAYS_HEAPCHECK) || defined(SOMETIMES_HEAPCHECK) 621 620 if (!_res_heap_check()) 622 621 { … … 655 654 PHEAPANCHOR pha; 656 655 657 #if def ALLWAYS_HEAPCHECK656 #if defined(ALLWAYS_HEAPCHECK) || defined(SOMETIMES_HEAPCHECK) 658 657 if (!_res_heap_check()) 659 658 { … … 778 777 void rfree(void *pv) 779 778 { 780 #if def ALLWAYS_HEAPCHECK781 782 783 784 785 779 #if defined(ALLWAYS_HEAPCHECK) || defined(SOMETIMES_HEAPCHECK) 780 if (!_res_heap_check()) 781 { 782 kprintf(("rfree: _res_heap_check failed!\n")); 783 return; 784 } 786 785 #endif 787 786 … … 825 824 826 825 #ifdef ALLWAYS_HEAPCHECK 827 828 826 if (!_res_heap_check()) 827 kprintf(("_res_msize: _res_heap_check failed!\n")); 829 828 #endif 830 829 … … 841 840 int _res_validptr(void *pv) 842 841 { 843 PHEAPANCHOR pha;844 842 PMEMBLOCK pmb; 845 843 846 844 #ifdef ALLWAYS_HEAPCHECK 847 848 845 if (!_res_heap_check()) 846 kprintf(("_res_validptr: _res_heap_check failed!\n")); 849 847 #endif 850 848 … … 862 860 int _res_validptr2(void *pv, unsigned cbSize) 863 861 { 864 PHEAPANCHOR pha;865 862 PMEMBLOCK pmb; 866 863 867 864 #ifdef ALLWAYS_HEAPCHECK 868 869 865 if (!_res_heap_check()) 866 kprintf(("_res_validptr: _res_heap_check failed!\n")); 870 867 #endif 871 868 … … 889 886 890 887 #ifdef ALLWAYS_HEAPCHECK 891 892 888 if (!_res_heap_check()) 889 kprintf(("_res_memfree: _res_heap_check failed!\n")); 893 890 #endif 894 891 … … 917 914 AVLENUMDATA FreeEnumData; 918 915 AVLENUMDATA UsedEnumData; 919 PMEMBLOCK pmbFree = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbFree, &FreeEnumData, TRUE); 920 PMEMBLOCK pmbFreeNext = (PMEMBLOCK)AVLGetNextNode(&FreeEnumData); 921 PMEMBLOCK pmbUsed = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbUsed, &UsedEnumData, TRUE); 922 PMEMBLOCK pmbUsedNext = (PMEMBLOCK)AVLGetNextNode(&UsedEnumData); 916 PMEMBLOCK pmbFree = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbFree, 917 SSToDS(&FreeEnumData), TRUE); 918 PMEMBLOCK pmbFreeNext = (PMEMBLOCK)AVLGetNextNode(SSToDS(&FreeEnumData)); 919 PMEMBLOCK pmbUsed = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbUsed, 920 SSToDS(&UsedEnumData), TRUE); 921 PMEMBLOCK pmbUsedNext = (PMEMBLOCK)AVLGetNextNode(SSToDS(&UsedEnumData)); 923 922 PMEMBLOCK pmbLast = NULL; 924 923 unsigned cbFree = 0; … … 1031 1030 pmbLast = pmbUsed; 1032 1031 pmbUsed = pmbUsedNext; 1033 pmbUsedNext = (PMEMBLOCK)AVLGetNextNode( &UsedEnumData);1032 pmbUsedNext = (PMEMBLOCK)AVLGetNextNode(SSToDS(&UsedEnumData)); 1034 1033 } 1035 1034 else … … 1071 1070 pmbLast = pmbFree; 1072 1071 pmbFree = pmbFreeNext; 1073 pmbFreeNext = (PMEMBLOCK)AVLGetNextNode( &FreeEnumData);1072 pmbFreeNext = (PMEMBLOCK)AVLGetNextNode(SSToDS(&FreeEnumData)); 1074 1073 } 1075 1074 } … … 1133 1132 1134 1133 1134 #ifdef DEBUG_ALLOC 1135 1135 /** 1136 1136 * Check the integrity of the a Free/Used AVL tree where Key == node pointer. … … 1143 1143 { 1144 1144 kprintf(("resCheckAVLTree: Invalid Key!\n")); 1145 Int3(); 1146 return -1; 1147 } 1148 if (pmb->core.Key % ALIGNMENT != 0) 1149 { 1150 kprintf(("resCheckAVLTree: Data is not correctly aligned, uData=0x%08x\n", pmb->core.Key)); 1145 1151 Int3(); 1146 1152 return -1; … … 1223 1229 return 0; 1224 1230 } 1231 #endif 1225 1232 1226 1233 … … 1289 1296 while (pha != NULL) 1290 1297 { 1291 PMEMBLOCK pmb; 1292 SUBHEAPS_CALLBACK_PARAM FreeParam = {0}; 1293 SUBHEAPS_CALLBACK_PARAM UsedParam = {0}; 1298 SUBHEAPS_CALLBACK_PARAM FreeParam = {0, 0}; 1299 SUBHEAPS_CALLBACK_PARAM UsedParam = {0, 0}; 1294 1300 1295 1301 AVLDoWithAll((PPAVLNODECORE)&pha->pmbUsed, 1, 1296 (PAVLCALLBACK)_res_dump_subheaps_callback, &UsedParam);1302 (PAVLCALLBACK)_res_dump_subheaps_callback, SSToDS(&UsedParam)); 1297 1303 AVLDoWithAll((PPAVLNODECORE)&pha->pmbFree, 1, 1298 (PAVLCALLBACK)_res_dump_subheaps_callback, &FreeParam);1304 (PAVLCALLBACK)_res_dump_subheaps_callback, SSToDS(&FreeParam)); 1299 1305 1300 1306 kprintf(("HeapAnchor %2d addr=0x%08x cbSize=%6d cbFree=%6d cbUsed=%6d cUsed=%4d cFree=%d\n", … … 1338 1344 { 1339 1345 PHEAPANCHOR pha; 1340 ALLOCATED_CALLBACK_PARAM Param = { 0};1346 ALLOCATED_CALLBACK_PARAM Param = {cb, 0, 0}; 1341 1347 1342 1348 kprintf(("----------------------------\n" … … 1349 1355 /* iterate thru tree using callback */ 1350 1356 AVLDoWithAll((PPAVLNODECORE)&pha->pmbUsed, TRUE, 1351 (PAVLCALLBACK)_res_dump_allocated_callback, &Param);1357 (PAVLCALLBACK)_res_dump_allocated_callback, SSToDS(&Param)); 1352 1358 1353 1359 /* next */
Note:
See TracChangeset
for help on using the changeset viewer.