Changeset 4164 for trunk/src/win32k/misc/rmalloc_avl.c
- Timestamp:
- Sep 2, 2000, 11:08:23 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/misc/rmalloc_avl.c
r2511 r4164 1 /* $Id: rmalloc_avl.c,v 1. 5 2000-01-24 18:19:00bird Exp $1 /* $Id: rmalloc_avl.c,v 1.6 2000-09-02 21:08:14 bird Exp $ 2 2 * 3 3 * Resident Heap - AVL. … … 47 47 ******************************************************************************/ 48 48 #include <os2.h> 49 #include "devSegDf.h" /* Win32k segment definitions. */ 49 50 #ifdef RING0 50 51 #include "dev32hlp.h" … … 120 121 static PHEAPANCHOR phaFirst; /* Pointer to the first anchor block.*/ 121 122 static PHEAPANCHOR phaLast; /* Pointer to the last anchor block.*/ 122 static unsignedcbResHeapMax; /* Maximum amount of memory used by the heap. */123 unsigned cbResHeapMax; /* Maximum amount of memory used by the heap. */ 123 124 124 125 #ifndef RING0 … … 898 899 899 900 /** 901 * Get amount of used memory (in bytes) 902 * @returns Amount of used memory (in bytes). 903 */ 904 unsigned _res_memused(void) 905 { 906 PHEAPANCHOR pha = phaFirst; 907 unsigned cb; 908 909 #ifdef ALLWAYS_HEAPCHECK 910 if (!_res_heap_check()) 911 kprintf(("_res_memused: _res_heap_check failed!\n")); 912 #endif 913 914 for (cb = 0; pha != NULL; pha = pha->pNext) 915 cb += pha->cbUsed; 916 917 return cb; 918 } 919 920 921 /** 922 * Collects the heap state. 923 * @returns 0 on success. 924 * -1 on error. 925 * @param pState Pointer to a RES_HEAPSTATE structure which is 926 * filled upon successful return. 927 */ 928 int _res_state(PHEAPSTATE pState) 929 { 930 PHEAPANCHOR pha; 931 932 #ifdef ALLWAYS_HEAPCHECK 933 if (!_res_heap_check()) 934 { 935 kprintf(("_res_state: _res_heap_check failed!\n")); 936 return -1; 937 } 938 #endif 939 940 if (pState == NULL) 941 return -1; 942 943 /* 944 * Loop thru all the anchor blocks and all memory blocks 945 * building the stats. 946 */ 947 memset(pState, 0, sizeof(HEAPSTATE)); 948 for (pha = phaFirst; pha != NULL; pha = pha->pNext) 949 { 950 AVLENUMDATA EnumData; 951 PAVLENUMDATA pEnumData = SSToDS(&EnumData); 952 PMEMBLOCK pmb; 953 954 /* count of free blocks */ 955 pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbFree, pEnumData, TRUE); 956 while (pmb) 957 { 958 pState->cBlocksFree++; 959 pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData); 960 } 961 962 /* count of used blocks */ 963 pmb = (PMEMBLOCK)AVLBeginEnumTree((PPAVLNODECORE)&pha->pmbUsed, pEnumData, TRUE); 964 while (pmb) 965 { 966 pState->cBlocksUsed++; 967 pmb = (PMEMBLOCK)AVLGetNextNode(pEnumData); 968 } 969 970 /* sizes */ 971 pState->cbHeapSize += pha->cbSize; 972 pState->cbHeapFree += pha->cbFree; 973 pState->cbHeapUsed += pha->cbUsed; 974 } 975 976 return 0; 977 } 978 979 980 /** 900 981 * Checks heap integrety. 901 982 * @returns TRUE when ok.
Note:
See TracChangeset
for help on using the changeset viewer.