~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/common/misc/sg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-10-17 23:23:09 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20111017232309-kzm6841lzk61ranj
Tags: 4.1.4-dfsg-1
* New upstream release.
  - Fixes missing icons when using pt_BR locale. (Closes: #507188)
  - Fixes guest additions download url. (Closes: #637349; LP: #840668)
* Refresh patches.
* Drop the vboxmouse x11 driver. The mouse integration is now completely
  handled by the kernel module.
* Restrict dh_pycentral to the virtualbox binary package.
* Merge changes from the Ubuntu package but use them only when built
  on Ubuntu:
  - Add an Apport hook.
  - Add vboxguest modalias to the package control field.
* Pass KBUILD_VERBOSE=2 to kmk.
* Add 36-fix-text-mode.patch to fix text mode when using the vboxvideo driver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: sg.cpp 36312 2011-03-18 12:59:15Z vboxsync $ */
 
1
/* $Id: sg.cpp $ */
2
2
/** @file
3
3
 * IPRT - S/G buffer handling.
4
4
 */
35
35
 
36
36
static void *sgBufGet(PRTSGBUF pSgBuf, size_t *pcbData)
37
37
{
38
 
    size_t cbData = RT_MIN(*pcbData, pSgBuf->cbSegLeft);
39
 
    void *pvBuf = pSgBuf->pvSegCur;
 
38
    size_t cbData;
 
39
    void *pvBuf;
 
40
 
 
41
    /* Check that the S/G buffer has memory left. */
 
42
    if (RT_UNLIKELY(   pSgBuf->idxSeg == pSgBuf->cSegs
 
43
                    && !pSgBuf->cbSegLeft))
 
44
    {
 
45
        *pcbData = 0;
 
46
        return NULL;
 
47
    }
40
48
 
41
49
    AssertReleaseMsg(      pSgBuf->cbSegLeft <= 5 * _1M
42
50
                     &&    (uintptr_t)pSgBuf->pvSegCur                     >= (uintptr_t)pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg
45
53
                      pSgBuf->idxSeg, pSgBuf->cSegs, pSgBuf->pvSegCur, pSgBuf->cbSegLeft,
46
54
                      pSgBuf->idxSeg, pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg, pSgBuf->idxSeg, pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg));
47
55
 
 
56
    cbData = RT_MIN(*pcbData, pSgBuf->cbSegLeft);
 
57
    pvBuf  = pSgBuf->pvSegCur;
48
58
    pSgBuf->cbSegLeft -= cbData;
49
59
 
50
60
    /* Advance to the next segment if required. */
52
62
    {
53
63
        pSgBuf->idxSeg++;
54
64
 
55
 
        if (RT_UNLIKELY(pSgBuf->idxSeg == pSgBuf->cSegs))
56
 
        {
57
 
            pSgBuf->cbSegLeft = 0;
58
 
            pSgBuf->pvSegCur  = NULL;
59
 
        }
60
 
        else
 
65
        if (pSgBuf->idxSeg < pSgBuf->cSegs)
61
66
        {
62
67
            pSgBuf->pvSegCur  = pSgBuf->paSegs[pSgBuf->idxSeg].pvSeg;
63
68
            pSgBuf->cbSegLeft = pSgBuf->paSegs[pSgBuf->idxSeg].cbSeg;