Changeset 31583 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Aug 11, 2010 9:34:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/sg.cpp
r30470 r31583 342 342 { 343 343 AssertPtrReturn(pSgBuf, 0); 344 AssertPtrReturn(paSeg, 0);345 344 AssertPtrReturn(pcSeg, 0); 346 345 346 unsigned cSeg = 0; 347 347 size_t cb = 0; 348 unsigned cSeg = 0; 349 350 while ( cbData 351 && cSeg < *pcSeg) 352 { 353 size_t cbThisSeg = cbData; 354 void *pvSeg = NULL; 355 356 pvSeg = sgBufGet(pSgBuf, &cbThisSeg); 357 358 if (!cbThisSeg) 359 { 360 Assert(!pvSeg); 361 break; 362 } 363 364 AssertMsg(cbThisSeg <= cbData, ("Impossible!\n")); 365 366 paSeg[cSeg].cbSeg = cbThisSeg; 367 paSeg[cSeg].pvSeg = pvSeg; 368 cSeg++; 369 cbData -= cbThisSeg; 370 cb += cbThisSeg; 348 349 if (!paSeg) 350 { 351 if (pSgBuf->cbSegLeft > 0) 352 { 353 size_t idx = pSgBuf->idxSeg; 354 cSeg = 1; 355 356 cb += RT_MIN(pSgBuf->cbSegLeft, cbData); 357 cbData -= RT_MIN(pSgBuf->cbSegLeft, cbData); 358 359 while ( cbData 360 && idx < pSgBuf->cSegs - 1) 361 { 362 idx++; 363 cSeg++; 364 cb += RT_MIN(pSgBuf->paSegs[idx].cbSeg, cbData); 365 cbData -= RT_MIN(pSgBuf->paSegs[idx].cbSeg, cbData); 366 } 367 } 368 } 369 else 370 { 371 while ( cbData 372 && cSeg < *pcSeg) 373 { 374 size_t cbThisSeg = cbData; 375 void *pvSeg = NULL; 376 377 pvSeg = sgBufGet(pSgBuf, &cbThisSeg); 378 379 if (!cbThisSeg) 380 { 381 Assert(!pvSeg); 382 break; 383 } 384 385 AssertMsg(cbThisSeg <= cbData, ("Impossible!\n")); 386 387 paSeg[cSeg].cbSeg = cbThisSeg; 388 paSeg[cSeg].pvSeg = pvSeg; 389 cSeg++; 390 cbData -= cbThisSeg; 391 cb += cbThisSeg; 392 } 371 393 } 372 394
Note:
See TracChangeset
for help on using the changeset viewer.