Appends chain with a single byte. Takes the single arg as the char to append, returns either E_OK if successful but E_MEMORY if not. The latter is a fatal condition. Returns: E_OK
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzChain::AddByte | (const char,) |
Declared in file: hzChain.h
Defined in file : hzChain.cpp
Function Logic:
Function body:
hzEcode hzChain::AddByte (const char C)
{
// Appends chain with a single byte. Takes the single arg as the char to append, returns either E_OK if successful but E_MEMORY
// if not. The latter is a fatal condition.
//
// Arguments: 1) C Char to add
//
// Returns: E_OK
_hzfunc("hzChain::AddByte") ;
// Place char C on the end of the chain. Must detect physical end of
// the current block and add new block
_zblk* curBlk ; // Working block pointer
_zblk* newBlk ; // Working block pointer
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)
Fatal("Chain %p has no end block\n", this) ;
if (curBlk->m_nUsage == ZBLKSIZE)
{
// Out of space - make new block
newBlk = _zblk_alloc() ;
newBlk->Prev(curBlk) ;
curBlk->Next(newBlk) ;
mx->m_End = curBlk = newBlk ;
}
curBlk->m_Data[curBlk->m_nUsage] = C ;
curBlk->m_nUsage++ ;
mx->m_nSize++ ;
return E_OK ;
}