| Return Type | Function name | Arguments |
|---|---|---|
| unsigned int | hzChain::AppendSub | (hzChain&,unsigned int,unsigned int,) |
Declared in file: hzChain.h
Defined in file : hzChain.cpp
Function Logic:
Function body:
unsigned int hzChain::AppendSub (hzChain& Z, unsigned int nStart, unsigned int nBytes)
{
_hzfunc("hzChain::Append(hzChain,Start,noBytes)") ;
chIter zi ;
_zblk* curBlk ;
_zblk* newBlk ;
uint32_t nBytesWritten = 0;
if (!Z.Size())
return 0;
if (!mx)
{ mx = new _chain() ; mx->m_Test = mx ; }
if (!mx->m_Begin)
mx->m_Begin = mx->m_End = _zblk_alloc() ;
curBlk = (_zblk*) mx->m_End ;
if (!curBlk)
hzexit(E_MEMORY, "Chain %p has no end block\n", this) ;
for (zi = Z, zi += nStart ; !zi.eof() && nBytesWritten < nBytes ; zi++)
{
if (curBlk->m_nUsage == ZBLKSIZE)
{
newBlk = _zblk_alloc() ;
newBlk->Prev(curBlk) ;
curBlk->Next(newBlk) ;
mx->m_End = curBlk = newBlk ;
}
curBlk->m_Data[curBlk->m_nUsage] = *zi ;
curBlk->m_nUsage++ ;
mx->m_nSize++ ;
nBytesWritten++ ;
}
return nBytesWritten ;
}