Changeset 19865 in vbox for trunk/src/VBox/Runtime/common/misc/handletable.cpp
- Timestamp:
- May 20, 2009 1:33:14 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 47538
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/handletable.cpp
r10789 r19865 48 48 PFNRTHANDLETABLERETAIN pfnRetain, void *pvUser) 49 49 { 50 PRTHANDLETABLEINT pThis; 51 uint32_t cLevel1; 52 size_t cb; 53 50 54 /* 51 55 * Validate input. … … 65 69 cMax = ((cMax + RTHT_LEVEL2_ENTRIES - 1) / RTHT_LEVEL2_ENTRIES) * RTHT_LEVEL2_ENTRIES; 66 70 67 uint32_t constcLevel1 = cMax / RTHT_LEVEL2_ENTRIES;71 cLevel1 = cMax / RTHT_LEVEL2_ENTRIES; 68 72 Assert(cLevel1 * RTHT_LEVEL2_ENTRIES == cMax); 69 73 … … 72 76 * if it's below the threshold size. 73 77 */ 74 size_tcb = sizeof(RTHANDLETABLEINT);78 cb = sizeof(RTHANDLETABLEINT); 75 79 if (cLevel1 < RTHT_LEVEL1_DYN_ALLOC_THRESHOLD) 76 80 cb = RT_ALIGN(cb, sizeof(void *)) + cLevel1 * sizeof(void *); 77 PRTHANDLETABLEINTpThis = (PRTHANDLETABLEINT)RTMemAllocZ(cb);81 pThis = (PRTHANDLETABLEINT)RTMemAllocZ(cb); 78 82 if (!pThis) 79 83 return VERR_NO_MEMORY; … … 121 125 RTDECL(int) RTHandleTableDestroy(RTHANDLETABLE hHandleTable, PFNRTHANDLETABLEDELETE pfnDelete, void *pvUser) 122 126 { 127 PRTHANDLETABLEINT pThis; 128 RTSPINLOCKTMP Tmp; 129 uint32_t i1; 130 uint32_t i; 131 123 132 /* 124 133 * Validate input, quitely ignore the NIL handle. … … 126 135 if (hHandleTable == NIL_RTHANDLETABLE) 127 136 return VINF_SUCCESS; 128 PRTHANDLETABLEINTpThis = (PRTHANDLETABLEINT)hHandleTable;137 pThis = (PRTHANDLETABLEINT)hHandleTable; 129 138 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 130 139 AssertReturn(pThis->u32Magic == RTHANDLETABLE_MAGIC, VERR_INVALID_HANDLE); … … 135 144 * Then kill the lock. 136 145 */ 137 RTSPINLOCKTMP Tmp;138 146 rtHandleTableLock(pThis, &Tmp); 139 147 ASMAtomicWriteU32(&pThis->u32Magic, ~RTHANDLETABLE_MAGIC); … … 157 165 if (pThis->fFlags & RTHANDLETABLE_FLAGS_CONTEXT) 158 166 { 159 for ( uint32_ti1 = 0; cLeft > 0 && i1 < pThis->cLevel1; i1++)167 for (i1 = 0; cLeft > 0 && i1 < pThis->cLevel1; i1++) 160 168 { 161 169 PRTHTENTRYCTX paTable = (PRTHTENTRYCTX)pThis->papvLevel1[i1]; 162 170 if (paTable) 163 for ( uint32_ti = 0; i < RTHT_LEVEL2_ENTRIES; i++)171 for (i = 0; i < RTHT_LEVEL2_ENTRIES; i++) 164 172 if (!RTHT_IS_FREE(paTable[i].pvObj)) 165 173 { … … 173 181 else 174 182 { 175 for ( uint32_ti1 = 0; cLeft > 0 && i1 < pThis->cLevel1; i1++)183 for (i1 = 0; cLeft > 0 && i1 < pThis->cLevel1; i1++) 176 184 { 177 185 PRTHTENTRY paTable = (PRTHTENTRY)pThis->papvLevel1[i1]; 178 186 if (paTable) 179 for ( uint32_ti = 0; i < RTHT_LEVEL2_ENTRIES; i++)187 for (i = 0; i < RTHT_LEVEL2_ENTRIES; i++) 180 188 if (!RTHT_IS_FREE(paTable[i].pvObj)) 181 189 { … … 193 201 * Free the memory. 194 202 */ 195 for ( uint32_ti1 = 0; i1 < pThis->cLevel1; i1++)203 for (i1 = 0; i1 < pThis->cLevel1; i1++) 196 204 if (pThis->papvLevel1[i1]) 197 205 {
Note:
See TracChangeset
for help on using the changeset viewer.