Changeset 26419 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Feb 10, 2010 11:21:14 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57523
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/alloc/memcache.cpp
r26418 r26419 207 207 while (iObj-- > 0) 208 208 if (ASMBitTestAndClear(pPage->pbmCtor, iObj)) 209 pThis->pfnDtor(hMemCache, (uint8_t *)pPage->pbObjects + iObj * pThis->cPerPage, pThis->pvUser);209 pThis->pfnDtor(hMemCache, pPage->pbObjects + iObj * pThis->cbObject, pThis->pvUser); 210 210 } 211 211 … … 238 238 */ 239 239 PRTMEMCACHEPAGE pPage = (PRTMEMCACHEPAGE)RTMemPageAlloc(PAGE_SIZE); 240 if (!pPage) 241 { 242 uint32_t cObjects = pThis->cPerPage; 243 if (pThis->cTotal + cObjects > pThis->cMax) 244 cObjects = pThis->cTotal - pThis->cMax; 240 if (pPage) 241 { 242 uint32_t const cObjects = RT_MIN(pThis->cPerPage, pThis->cMax - pThis->cTotal); 245 243 246 244 ASMMemZeroPage(pPage); … … 248 246 pPage->pNext = NULL; 249 247 pPage->cFree = cObjects; 250 pPage->pbmAlloc = (pThis + 1); 248 pPage->cObjects = cObjects; 249 pPage->pbmAlloc = pPage + 1; 251 250 pPage->pbmCtor = (uint8_t *)pPage->pbmAlloc + pThis->cBits / 8; 252 251 pPage->pbObjects = (uint8_t *)pPage->pbmCtor + pThis->cBits / 8; … … 317 316 { 318 317 ASMAtomicIncS32(&pThis->cFree); 319 return VERR_ CACHE_EMPTY;318 return VERR_MEM_CACHE_MAX_SIZE; 320 319 } 321 320 … … 369 368 else if (!ASMAtomicBitTestAndSet(pPage->pbmAlloc, iObj)) 370 369 break; 371 Assert(cLoops2 != 2); 372 Assert(cLoops2 != 10); 370 Assert(cLoops2 != 40); 373 371 } 374 372 Assert(iObj >= 0); 375 373 } 376 374 void *pvObj = &pPage->pbObjects[iObj * pThis->cbObject]; 375 Assert((uintptr_t)pvObj - (uintptr_t)pPage < PAGE_SIZE); 377 376 378 377 /* … … 391 390 } 392 391 392 *ppvObj = pvObj; 393 393 return VINF_SUCCESS; 394 394 } … … 423 423 * Find the cache page. The page structure is at the start of the page. 424 424 */ 425 PRTMEMCACHEPAGE pPage = (PRTMEMCACHEPAGE)(((uintptr_t)pvObj) & ~(uintptr_t)PAGE_ SIZE);425 PRTMEMCACHEPAGE pPage = (PRTMEMCACHEPAGE)(((uintptr_t)pvObj) & ~(uintptr_t)PAGE_OFFSET_MASK); 426 426 AssertReturnVoid(pPage->pCache == pThis); 427 427 AssertReturnVoid(ASMAtomicUoReadS32(&pPage->cFree) < (int32_t)pThis->cPerPage); … … 430 430 * Clear the bitmap bit and update the two object counter. Order matters! 431 431 */ 432 uintptr_t iObj = (uintptr_t)pvObj - (uintptr_t)pPage->pbObjects; 433 AssertReturnVoid(iObj < pThis->cPerPage); 432 uintptr_t offObj = (uintptr_t)pvObj - (uintptr_t)pPage->pbObjects; 433 uintptr_t iObj = offObj / pThis->cbObject; 434 AssertReturnVoid(iObj * pThis->cbObject == offObj); 435 Assert(iObj < pThis->cPerPage); 434 436 AssertReturnVoid(ASMAtomicBitTestAndClear(pPage->pbmAlloc, iObj)); 435 437 -
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r26224 r26419 78 78 tstLog \ 79 79 tstMemAutoPtr \ 80 tstRTMemCache \ 80 81 tstRTMemPool \ 81 82 tstRTR0MemUserKernelDriver \ … … 309 310 tstMemAutoPtr_SOURCES = tstMemAutoPtr.cpp 310 311 312 tstRTMemCache_TEMPLATE = VBOXR3TSTEXE 313 tstRTMemCache_SOURCES = tstRTMemCache.cpp 314 311 315 tstRTMemPool_TEMPLATE = VBOXR3TSTEXE 312 316 tstRTMemPool_SOURCES = tstRTMemPool.cpp
Note:
See TracChangeset
for help on using the changeset viewer.