Appends the chain with the first nBytes nB (void*) buffer of given size. This operation makes no assumptions about buffer content and so the operation is not null terminated.

Return TypeFunction nameArguments
uint32_thzXbuf::Append(const void*,uint32_t,)

Declared in file: hzXbuf.h
Defined in file : hzXbuf.cpp

Function Logic:

0:START 1:unknown 2:Return nBytes 3:unknown 4:mx 5:unknown 6:mx 7:mx 8:curBlk 9:unknown 10:items 11:i 12:unknown 13:unknown 14:newBlk 15:unknown 16:items 17:items mx curBlk XBLKSIZE 18:nCan 19:unknown 20:nBytes 21:nCan 22:items curBlk i mx nWritten 23:Return nWritten

Function body:

uint32_t hzXbuf::Append (const void* vpStr)uint32_t nBytes, 
{
   //  Appends the chain with the first nBytes nB (void*) buffer of given size. This operation makes no assumptions about buffer content and so the operation is
   //  not null terminated.
   //  
   //  Arguments: 1) vpStr The buffer address as void*
   //     2) nBytes The number of bytes from the buffer to append to the chain
   //  
   //  Returns: Number of bytes added
   _hzfunc("hzXbuf::Append(1)") ;
   _xblk*      curBlk ;            //  Working block pointer
   _xblk*      newBlk ;            //  Working block pointer
   const char* i ;                 //  Input iterator
   uint32_t    nCan ;              //  Max number of bytes that can be written to current block
   uint32_t    nWritten = 0;       //  Limiter
   if (!nBytes)
       return nBytes ;
   //  If nothing in chain, create the first block
   if (!mx)
       mx = new _xbuf() ;
   if (!mx->m_Begin)
       mx->m_Begin = mx->m_End = _xblk_alloc() ;
   curBlk = (_xblk*) mx->m_End ;
   if (!curBlk)
       Fatal("Chain %p has no end block\n", this) ;
   i = (char*) vpStr ;
   for (; nWritten < nBytes ;)
   {
       if (curBlk->xize == XBLKSIZE)
       {
           //  Out of space - make new block
           newBlk = _xblk_alloc() ;
           if (!newBlk)
               Fatal("No allocation (case 2)\n") ;
           //  newBlk->Prev((_xblk*) mx->m_End) ;
           curBlk->Next(newBlk) ;
           mx->m_End = newBlk ;
           curBlk = newBlk ;
       }
       nCan = XBLKSIZE - curBlk->xize ;
       if ((nWritten + nCan) > nBytes)
           nCan = nBytes - nWritten ;
       //  Add bytes to current block
       memcpy(curBlk->m_Data + curBlk->xize, i, nCan) ;
       curBlk->xize += nCan ;
       i += nCan ;
       mx->m_nSize += nCan ;
       nWritten += nCan ;
   }
   return nWritten ;
}