Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

static int krdrBufWrapIt ( PPKRDR  ppRdr,
PKRDR  pRdrWrapped,
KBOOL  fCloseIt 
) [static]

Worker for kRdrBufOpen and kRdrBufWrap.

It's essentially kRdrBufWrap without error checking.

Returns:
0 on success, one of the kErrors status code on failure.
Parameters:
ppRdr Where to store the new file provider instance.
pRdrWrapped The file provider instance to buffer.
fCloseIt Whether it the pRdrWrapped instance should be closed when the new instance is closed.

Definition at line 396 of file kRdrBuffered.cpp.

References KRDRBUF::cbBuf, KRDRBUF::cbBufValid, KRDRBUF::cbFile, KRDRBUF::Core, KRDRBUF::fCloseIt, KRDRBUF::fTainedByLineQ, K_FALSE, KERR_NO_MEMORY, KRDR_MAGIC, KSIZE, KRDRBUF::offBuf, KRDRBUF::offBufEnd, KRDRBUF::offFile, KRDRBUF::pbBuf, KRDROPS::pfnSize, KRDROPS::pfnTell, KRDR::pOps, KRDRBUF::pRdr, and KRDR::u32Magic.

{
    PKRDRBUF pThis = (PKRDRBUF)kHlpAlloc(sizeof(*pThis));
    if (pThis)
    {
        pThis->Core.u32Magic = KRDR_MAGIC;
        pThis->Core.pOps = &g_krdrBufOps;
        pThis->pRdr = pRdrWrapped;
        pThis->offFile = pRdrWrapped->pOps->pfnTell(pRdrWrapped);
        pThis->cbFile = pRdrWrapped->pOps->pfnSize(pRdrWrapped);
        pThis->offBuf = pThis->offBufEnd = 0;
        pThis->cbBufValid = 0;
        pThis->fCloseIt = fCloseIt;
        pThis->fTainedByLineQ = K_FALSE;
        if (pThis->cbFile < 128*1024)
            pThis->cbBuf = (KSIZE)pThis->cbFile + 1; /* need space for the kRdrBufLineQ terminator. */
        else
            pThis->cbBuf = 64*1024;
        pThis->pbBuf = (KU8 *)kHlpAlloc(pThis->cbBuf);
        if (pThis->pbBuf)
        {
            *ppRdr = &pThis->Core;
            return 0;
        }

        pThis->Core.u32Magic = 0;
        kHlpFree(pThis);
    }
    return KERR_NO_MEMORY;
}


Generated by  Doxygen 1.6.0   Back to index