VirtualBox

Changeset 28113 in vbox


Ignore:
Timestamp:
Apr 8, 2010 8:11:33 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59831
Message:

Runtime/Sg: Add a method to advance the internal buffer pointer

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/sg.h

    r28053 r28113  
    169169
    170170/**
     171 * Advances the internal buffer pointer.
     172 *
     173 * @returns Number of bytes the pointer was moved forward.
     174 * @param   pSgBuf      The S/G buffer.
     175 * @param   cbAdvance   Number of bytes to move forward.
     176 */
     177RTDECL(size_t) RTSgBufAdvance(PRTSGBUF pSgBuf, size_t cbAdvance);
     178
     179/**
    171180 * Constructs a new segment array starting from the current position
    172181 * and describing the given number of bytes.
  • trunk/src/VBox/Runtime/common/misc/sg.cpp

    r28053 r28113  
    250250
    251251
     252RTDECL(size_t) RTSgBufAdvance(PRTSGBUF pSgBuf, size_t cbAdvance)
     253{
     254    AssertPtrReturn(pSgBuf, 0);
     255
     256    size_t cbLeft = cbAdvance;
     257
     258    while (cbLeft)
     259    {
     260        size_t cbThisAdvance = cbLeft;
     261        void *pv = sgBufGet(pSgBuf, &cbThisAdvance);
     262
     263        NOREF(pv);
     264
     265        if (!cbThisAdvance)
     266            break;
     267
     268        cbLeft -= cbThisAdvance;
     269    }
     270
     271    return cbAdvance - cbLeft;
     272}
     273
     274
    252275RTDECL(size_t) RTSgBufSegArrayCreate(PRTSGBUF pSgBuf, PRTSGSEG paSeg, unsigned *pcSeg, size_t cbData)
    253276{
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