VirtualBox

Changeset 64682 in vbox for trunk


Ignore:
Timestamp:
Nov 16, 2016 2:00:45 PM (8 years ago)
Author:
vboxsync
Message:

Storage/IOBufMgmt: Fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/IOBufMgmt.cpp

    r64674 r64682  
    189189    /* Round to the next power of two and get the bin to try first. */
    190190    uint32_t u32Order = ASMBitLastSetU32((uint32_t)cb) - 1;
    191     if (cbAlloc & ~RT_BIT_32(u32Order))
    192         u32Order <<= 1;
     191    if (cb & (RT_BIT_32(u32Order) - 1))
     192        u32Order++;
    193193
    194194    u32Order = RT_CLAMP(u32Order, pThis->u32OrderMin, pThis->u32OrderMax);
     
    374374        unsigned iSeg = 0;
    375375        size_t   cbLeft = cbIoBuf;
     376        size_t   cbIoBufAlloc = 0;
    376377        PRTSGSEG pSeg = &pIoBufDesc->Int.aSegs[0];
    377378
     
    386387            pSeg++;
    387388            cbLeft -= RT_MIN(cbAlloc, cbLeft);
     389            cbIoBufAlloc += cbAlloc;
    388390        }
    389391
     
    395397        pIoBufDesc->Int.cSegsUsed = iSeg;
    396398        pIoBufDesc->Int.pIoBufMgr = pThis;
    397         *pcbIoBufAllocated = cbIoBuf - cbLeft;
     399        *pcbIoBufAllocated = cbIoBufAlloc;
    398400        Assert(   (RT_SUCCESS(rc) && *pcbIoBufAllocated > 0)
    399401               || RT_FAILURE(rc));
    400402
    401         pThis->cbFree -= cbIoBuf - cbLeft;
     403        pThis->cbFree -= cbIoBufAlloc;
    402404
    403405        RTCritSectLeave(&pThis->CritSectAlloc);
     
    429431            pBin->papvFree[pBin->iFree] = pSeg->pvSeg;
    430432            pBin->iFree++;
    431             pThis->cbFree += (size_t)RT_BIT_32(u32Order);
     433            pThis->cbFree += pSeg->cbSeg;
    432434        }
    433435
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