- Timestamp:
- Apr 6, 2016 9:34:14 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/sg.h
r59746 r60346 80 80 * @param paSegs Pointer to the start of the segment array. 81 81 * @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. 82 86 */ 83 87 RTDECL(void) RTSgBufInit(PRTSGBUF pSgBuf, PCRTSGSEG paSegs, size_t cSegs); -
trunk/src/VBox/Runtime/common/misc/sg.cpp
r59747 r60346 84 84 { 85 85 AssertPtr(pSgBuf); 86 Assert Ptr(paSegs);87 Assert(cSegs > 0);86 Assert( (cSegs > 0 && VALID_PTR(paSegs)) 87 || (!cSegs && !paSegs)); 88 88 Assert(cSegs < (~(unsigned)0 >> 1)); 89 89 … … 91 91 pSgBuf->cSegs = (unsigned)cSegs; 92 92 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 } 95 103 } 96 104 … … 100 108 AssertPtrReturnVoid(pSgBuf); 101 109 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 } 105 121 } 106 122
Note:
See TracChangeset
for help on using the changeset viewer.