Clears all content held by the hzXbuf. Arguments: None Returns: None

Return TypeFunction nameArguments
voidhzXbuf::Clear(void)

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

Function Logic:

0:START 1:unknown 2: No text 3:cx mx 4:unknown 5:items 6:unknown 7: No text 8:items 9:unknown 10: No text 11:unknown 12:items 13:unknown 14:items 15:zp items s_xblk_free cx cx cx cx count 16:unknown 17:items 18:_hzGlobal_Memstats items 19:cx 20: No text

Function body:

void hzXbuf::Clear (void)
{
   //  Clears all content held by the hzXbuf.
   //  
   //  Arguments: None
   //  Returns: None
   _hzfunc("hzXbuf::Clear") ;
   _xbuf*      cx ;        //  Temp pointer to control
   _xblk*      zp ;        //  Block pointer
   uint32_t    count ;     //  Number of blocks in chain
   //  Already no content - no action required.
   if (!mx)
       return ;
   //  If this chain is one of many pointing to the same contents, decrement the copy count and detach this chain from the contents.
   cx = mx ;
   mx = 0;
    if (_hzGlobal_MT)
    {
        __sync_add_and_fetch((uint32_t*)&(cx->m_copy), -1);
        if (cx->m_copy)
           return ;
    }
    else
    {
        cx->m_copy-- ;
        if (cx->m_copy)
           return ;
    }
   if (cx->m_Begin)
   {
       //  Delete by returning all blocks to the free list. As the blocks are linked, we only need to set the next pointer in the last block to the free list and then set the free
       //  list to the first block.
       s_xbuf_mutex.LockWrite() ;
           //  Check for corruption
           if (!cx->m_End)
               hzexit(E_CORRUPT, "The internal begin/end blocks are %p and %p", cx->m_Begin, cx->m_End) ;
           zp = (_xblk*) cx->m_End ;
           zp->Next(s_xblk_free) ;
           s_xblk_free = (_xblk*) cx->m_Begin ;
           cx->m_Begin = cx->m_End = 0;
           cx->m_nSize = 0;
           count = cx->m_nSize / XBLKSIZE ;
           if (cx->m_nSize % XBLKSIZE)
               count++ ;
           _hzGlobal_Memstats.m_numChainBF += count ;
       s_xbuf_mutex.Unlock() ;
   }
   delete cx ;
}