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

Return TypeFunction nameArguments
voidhzChain::Clear(void)

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

Function Logic:

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

Function body:

void hzChain::Clear (void)
{
   //  Clears all content held by the hzChain.
   //  
   //  Arguments: None
   //  Returns: None
   _hzfunc("hzChain::Clear") ;
   _chain*     cx ;        //  Temp pointer to control
   _zblk*      zp ;        //  Block pointer
   _zblk*      np ;        //  Next block pointer
   //  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 (cx->m_Test != cx)
       hzexit(E_CORRUPT, "Chain is not self addressing") ;
   if (cx->m_copy <&eq; 0)
       hzexit(E_CORRUPT, "Copy count must be at least 1 in live chain") ;
    if (_hzGlobal_MT)
    {
        __sync_add_and_fetch(&(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_chain_mutex.LockWrite() ;
           //  Check for corruption
           if (!cx->m_End)
               hzexit(E_CORRUPT, "No end block") ;
           //  Loop through blocks and delete them
           for (zp = (_zblk*) cx->m_Begin ; zp ; zp = np)
           {
               np = zp->Next() ;
               delete zp ;
               _hzGlobal_Memstats.m_numChainBlks-- ;
           }
       s_chain_mutex.Unlock() ;
   }
   delete cx ;
}