VirtualBox

Changeset 20561 in vbox for trunk


Ignore:
Timestamp:
Jun 14, 2009 6:37:44 PM (15 years ago)
Author:
vboxsync
Message:

iprt: Implemented RTMemPoolDestroy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/mempool-generic.cpp

    r20360 r20561  
    159159RTDECL(int) RTMemPoolDestroy(RTMEMPOOL hMemPool)
    160160{
    161 
    162     return VERR_NOT_IMPLEMENTED;
    163 }
    164 
     161    if (hMemPool == NIL_RTMEMPOOL)
     162        return VINF_SUCCESS;
     163    PRTMEMPOOLINT pMemPool = hMemPool;
     164    RTMEMPOOL_VALID_RETURN_RC(pMemPool, VERR_INVALID_HANDLE);
     165    if (pMemPool == &g_rtMemPoolDefault)
     166        return VINF_SUCCESS;
     167
     168    /*
     169     * Invalidate the handle and free all associated resources.
     170     */
     171    ASMAtomicWriteU32(&pMemPool->u32Magic, RTMEMPOOL_MAGIC_DEAD);
     172
     173    int rc = RTSpinlockDestroy(pMemPool->hSpinLock); AssertRC(rc);
     174    pMemPool->hSpinLock = NIL_RTSPINLOCK;
     175
     176    PRTMEMPOOLENTRY pEntry = pMemPool->pHead;
     177    pMemPool->pHead = NULL;
     178    while (pEntry)
     179    {
     180        PRTMEMPOOLENTRY pFree = pEntry;
     181        pEntry = pEntry->pNext;
     182
     183        pFree->pMemPool = NULL;
     184        pFree->pNext = NULL;
     185        pFree->pPrev = NULL;
     186        pFree->cRefs = UINT32_MAX - 3;
     187        RTMemFree(pFree);
     188    }
     189
     190    RTMemFree(pMemPool);
     191
     192    return VINF_SUCCESS;
     193}
    165194
    166195
     
    353382    {
    354383        rtMemPoolUnlink(pEntry);
     384        pEntry->cRefs = UINT32_MAX - 2;
    355385        RTMemFree(pEntry);
    356386    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette