Append the current chain with the supplied char string operand.
| Return Type | Function name | Arguments |
|---|---|---|
| hzChain& | hzChain::operator+= | (const char*,) |
Declared in file: hzChain.h
Defined in file : hzChain.cpp
Function Logic:
Function body:
hzChain& hzChain::operator+= (const char* s)
{
// Append the current chain with the supplied char string operand.
//
// Arguments: 1) s The null terminated string to add to the chain
//
// Returns: Reference to this chain
_hzfunc("hzChain::operator+=(char*)") ;
_zblk* curBlk ; // Block pointer
_zblk* newBlk ; // Working block pointer
const char* i ; // Supplied string iterator
if (!s || !s[0])
return *this ;
// If nothing in chain, create the first block
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) ;
for (i = s ; *i ; i++)
{
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] = *i ;
curBlk->m_nUsage++ ;
mx->m_nSize++ ;
}
return *this ;
}