Return TypeFunction nameArguments
hzString&hzString::TruncateBeyond(const char*,)

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

Function Logic:

0:START 1:!patern||!patern[0] 2:Return *this 3:!m_addr 4:Return *this 5:_strXlate thisCtl _strItem::_data strstr i 6:!i 7:Return *this 8:_strItem::_data newLen _strAlloc destAddr _strXlate destCtl _strItem::_setSize destCtl strlen i 9:*i; 10:* 11:thisCtl->m_copy&&thisCtl->m_copy<50 12:!_hzGlobal_MT 13:items 14:!thisCtl->m_copy 15:_strItem::_getSize _strFree 16:__sync_add_and_fetch(&(thisCtl->m_copy),-1)==0 17:_strItem::_getSize _strFree 18:m_addr 19:Return *this

Function body:

hzString& hzString::TruncateBeyond (const char* patern)
{
   _hzfunc("hzString::TruncateBeyond") ;
   _strItem*       thisCtl ;
   _strItem*       destCtl ;
   char*           i ;
   char*           j ;
   uint32_t        destAddr ;
   uint32_t        newLen ;
   if (!patern || !patern[0])
       return *this ;
   if (!m_addr)
       return *this ;
   thisCtl = (_strItem*) _strXlate(m_addr) ;
   i = strstr((char*) thisCtl->_data(), patern) ;
   if (!i)
       return *this ;
   newLen = i - thisCtl->_data() ;
   destAddr = _strAlloc(newLen) ;
   destCtl = (_strItem*) _strXlate(destAddr) ;
   destCtl->_setSize(newLen) ;
   destCtl->m_copy = 1;
   i += strlen(patern) ;
   for (j = destCtl->_data() ; *i ; *j++ = *i++) ;
   *j = 0;
   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 ;
}