Increments the current chain iterator by the requested length. Will set the iterator to the end of the chain if the requested increment is too great.
| Return Type | Function name | Arguments |
|---|---|---|
| uint32_t | hzXbuf::Iter::Advance | (uint32_t,) |
Declared in file: hzXbuf.h
Defined in file : hzXbuf.cpp
Function Logic:
Function body:
uint32_t hzXbuf::Iter::Advance (uint32_t nInc)
{
// Increments the current chain iterator by the requested length. Will set the iterator to the end of the chain if the requested
// increment is too great.
//
// Arguments: 1) nInc Number of bytes to advance
//
// Returns: Number of bytes advanced
_hzfunc("hzXbuf::Iter::Advance") ;
_xblk* zp ; // Chain block pointer
uint32_t nCan ; // Advance possibible within current block
uint32_t nAdv = 0; // Number of chars actully advanced
if (nInc < 0)
return 0;
zp = (_xblk*) m_block ;
if (!zp)
return 0;
for (; nAdv < nInc ;)
{
nCan = zp->xize - m_nOset ;
if ((nCan + nAdv) > nInc)
nCan = nInc - nAdv ;
m_nOset += nCan ;
nAdv += nCan ;
if (m_nOset == zp->xize)
{
if (!zp->Next())
break ;
m_nOset = 0;
m_block = zp = zp->Next() ;
}
}
return nAdv ;
}