Lines Matching refs:pSgBuf

37 static void *sgBufGet(PRTSGBUF pSgBuf, size_t *pcbData)
43 if (RT_UNLIKELY( pSgBuf->idxSeg == pSgBuf->cSegs
44 && !pSgBuf->cbSegLeft))
51 AssertReleaseMsg( pSgBuf->cbSegLeft <= 32 * _1M
52 && (uintptr_t)pSgBuf->pvSegCur >= (uintptr_t)pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg
53 && (uintptr_t)pSgBuf->pvSegCur + pSgBuf->cbSegLeft <= (uintptr_t)pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg + pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg,
54 ("pSgBuf->idxSeg=%d pSgBuf->cSegs=%d pSgBuf->pvSegCur=%p pSgBuf->cbSegLeft=%zd pSgBuf->paSegs[%d].pvSeg=%p pSgBuf->paSegs[%d].cbSeg=%zd\n",
55 pSgBuf->idxSeg, pSgBuf->cSegs, pSgBuf->pvSegCur, pSgBuf->cbSegLeft,
56 pSgBuf->idxSeg, pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg, pSgBuf->idxSeg, pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg));
59 cbData = RT_MIN(*pcbData, pSgBuf->cbSegLeft);
60 pvBuf = pSgBuf->pvSegCur;
61 pSgBuf->cbSegLeft -= cbData;
64 if (!pSgBuf->cbSegLeft)
66 pSgBuf->idxSeg++;
68 if (pSgBuf->idxSeg < pSgBuf->cSegs)
70 pSgBuf->pvSegCur = pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg;
71 pSgBuf->cbSegLeft = pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg;
77 pSgBuf->pvSegCur = (uint8_t *)pSgBuf->pvSegCur + cbData;
83 RTDECL(void) RTSgBufInit(PRTSGBUF pSgBuf, PCRTSGSEG paSegs, size_t cSegs)
85 AssertPtr(pSgBuf);
90 pSgBuf->paSegs = paSegs;
91 pSgBuf->cSegs = (unsigned)cSegs;
92 pSgBuf->idxSeg = 0;
93 pSgBuf->pvSegCur = paSegs[0].pvSeg;
94 pSgBuf->cbSegLeft = paSegs[0].cbSeg;
98 RTDECL(void) RTSgBufReset(PRTSGBUF pSgBuf)
100 AssertPtrReturnVoid(pSgBuf);
102 pSgBuf->idxSeg = 0;
103 pSgBuf->pvSegCur = pSgBuf->paSegs[0].pvSeg;
104 pSgBuf->cbSegLeft = pSgBuf->paSegs[0].cbSeg;
121 RTDECL(void *) RTSgBufGetNextSegment(PRTSGBUF pSgBuf, size_t *pcbSeg)
123 AssertPtrReturn(pSgBuf, NULL);
127 *pcbSeg = pSgBuf->cbSegLeft;
129 return sgBufGet(pSgBuf, pcbSeg);
272 RTDECL(size_t) RTSgBufSet(PRTSGBUF pSgBuf, uint8_t ubFill, size_t cbSet)
274 AssertPtrReturn(pSgBuf, 0);
281 void *pvBuf = sgBufGet(pSgBuf, &cbThisSet);
295 RTDECL(size_t) RTSgBufCopyToBuf(PRTSGBUF pSgBuf, void *pvBuf, size_t cbCopy)
297 AssertPtrReturn(pSgBuf, 0);
305 void *pvSrc = sgBufGet(pSgBuf, &cbThisCopy);
320 RTDECL(size_t) RTSgBufCopyFromBuf(PRTSGBUF pSgBuf, const void *pvBuf, size_t cbCopy)
322 AssertPtrReturn(pSgBuf, 0);
330 void *pvDst = sgBufGet(pSgBuf, &cbThisCopy);
345 RTDECL(size_t) RTSgBufAdvance(PRTSGBUF pSgBuf, size_t cbAdvance)
347 AssertPtrReturn(pSgBuf, 0);
354 void *pv = sgBufGet(pSgBuf, &cbThisAdvance);
368 RTDECL(size_t) RTSgBufSegArrayCreate(PRTSGBUF pSgBuf, PRTSGSEG paSeg, unsigned *pcSeg, size_t cbData)
370 AssertPtrReturn(pSgBuf, 0);
378 if (pSgBuf->cbSegLeft > 0)
380 size_t idx = pSgBuf->idxSeg;
383 cb += RT_MIN(pSgBuf->cbSegLeft, cbData);
384 cbData -= RT_MIN(pSgBuf->cbSegLeft, cbData);
387 && idx < pSgBuf->cSegs - 1)
391 cb += RT_MIN(pSgBuf->paSegs[idx].cbSeg, cbData);
392 cbData -= RT_MIN(pSgBuf->paSegs[idx].cbSeg, cbData);
404 pvSeg = sgBufGet(pSgBuf, &cbThisSeg);
427 RTDECL(bool) RTSgBufIsZero(PRTSGBUF pSgBuf, size_t cbCheck)
433 RTSgBufClone(&SgBufTmp, pSgBuf);