Return TypeFunction nameArguments
hzString&hzString::Truncate(unsigned int,)

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

Function Logic:

0:START 1:!m_addr 2:Return *this 3:_strXlate thisCtl 4:limit>=thisCtl->_getSize() 5:Return *this 6:limit 7:_strAlloc destAddr _strXlate destCtl _strItem::_setSize _strItem::_data _strItem::_data memcpy destCtl 8:thisCtl->m_copy&&thisCtl->m_copy<50 9:!_hzGlobal_MT 10:items 11:!thisCtl->m_copy 12:_strItem::_getSize _strFree 13:__sync_add_and_fetch(&(thisCtl->m_copy),-1)==0 14:_strItem::_getSize _strFree 15:m_addr 16:Return *this

Function body:

hzString& hzString::Truncate (unsigned int limit)
{
   _hzfunc("hzString::Truncate") ;
   _strItem*   thisCtl ;
   _strItem*   destCtl ;
   uint32_t    destAddr = 0;
   if (!m_addr)
       return *this ;
   thisCtl = (_strItem*) _strXlate(m_addr) ;
   if (limit >&eq; thisCtl->_getSize())
       return *this ;
   if (limit)
   {
       destAddr = _strAlloc(limit) ;
       destCtl = (_strItem*) _strXlate(destAddr) ;
       destCtl->_setSize(limit) ;
       memcpy(destCtl->_data(), thisCtl->_data(), limit) ;
       destCtl->m_copy = 1;
   }
   if (thisCtl->m_copy && thisCtl->m_copy < 50)
   {
       if (!_hzGlobal_MT)
       {
           thisCtl->m_copy-- ;
           if (!thisCtl->m_copy)
               _strFree(m_addr, thisCtl->_getSize()) ;
       }
       else
       {
           if (__sync_add_and_fetch(&(thisCtl->m_copy), -1)== 0)
               _strFree(m_addr, thisCtl->_getSize()) ;
       }
   }
   m_addr = destAddr ;
   return *this ;
}