VirtualBox

儲存庫 vbox 的更動 60346


忽略:
時間撮記:
2016-4-6 上午09:34:14 (9 年 以前)
作者:
vboxsync
訊息:

Runtime/sg.cpp: Allow RTSgBufInit to take NULL and 0 for paSegs and cSegs respectively to indicate an empty buffer

位置:
trunk
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/iprt/sg.h

    r59746 r60346  
    8080 * @param   paSegs    Pointer to the start of the segment array.
    8181 * @param   cSegs     Number of segments in the array.
     82 *
     83 * @note paSegs and cSegs can be NULL and 0 respectively to indicate
     84 *       an empty S/G buffer. All operations on the S/G buffer will
     85 *       not do anything in this case.
    8286 */
    8387RTDECL(void) RTSgBufInit(PRTSGBUF pSgBuf, PCRTSGSEG paSegs, size_t cSegs);
  • trunk/src/VBox/Runtime/common/misc/sg.cpp

    r59747 r60346  
    8484{
    8585    AssertPtr(pSgBuf);
    86     AssertPtr(paSegs);
    87     Assert(cSegs > 0);
     86    Assert(   (cSegs > 0 && VALID_PTR(paSegs))
     87           || (!cSegs && !paSegs));
    8888    Assert(cSegs < (~(unsigned)0 >> 1));
    8989
     
    9191    pSgBuf->cSegs     = (unsigned)cSegs;
    9292    pSgBuf->idxSeg    = 0;
    93     pSgBuf->pvSegCur  = paSegs[0].pvSeg;
    94     pSgBuf->cbSegLeft = paSegs[0].cbSeg;
     93    if (cSegs && paSegs)
     94    {
     95        pSgBuf->pvSegCur  = paSegs[0].pvSeg;
     96        pSgBuf->cbSegLeft = paSegs[0].cbSeg;
     97    }
     98    else
     99    {
     100        pSgBuf->pvSegCur  = NULL;
     101        pSgBuf->cbSegLeft = 0;
     102    }
    95103}
    96104
     
    100108    AssertPtrReturnVoid(pSgBuf);
    101109
    102     pSgBuf->idxSeg    = 0;
    103     pSgBuf->pvSegCur  = pSgBuf->paSegs[0].pvSeg;
    104     pSgBuf->cbSegLeft = pSgBuf->paSegs[0].cbSeg;
     110    pSgBuf->idxSeg = 0;
     111    if (pSgBuf->cSegs)
     112    {
     113        pSgBuf->pvSegCur  = pSgBuf->paSegs[0].pvSeg;
     114        pSgBuf->cbSegLeft = pSgBuf->paSegs[0].cbSeg;
     115    }
     116    else
     117    {
     118        pSgBuf->pvSegCur  = NULL;
     119        pSgBuf->cbSegLeft = 0;
     120    }
    105121}
    106122
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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