Reverse the string content. This first ensures the string is independent. Arguments: None

Return TypeFunction nameArguments
hzString&hzString::Reverse(void)

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

Function Logic:

0:START 1:unknown 2:Return *this 3:thisCtl nLen destAddr destCtl items destCtl nLen c_down pSrc pTgt 4:unknown 5:pTgt 6:unknown 7:unknown 8:items 9:unknown 10:items 11:unknown 12:items 13:m_addr 14:Return *this

Function body:

hzString& hzString::Reverse (void)
{
   //  Reverse the string content. This first ensures the string is independent.
   //  
   //  Arguments: None
   //  Returns: Reference to this string in all cases
   _hzfunc("hzString::Reverse") ;
   _strItem*   thisCtl ;   //  This string's control area
   _strItem*   destCtl ;   //  New internal structure if required
   char*       pTgt ;      //  Target internal value
   char*       pSrc ;      //  Source internal value
   uint32_t    destAddr ;  //  New string address if required
   uint32_t    nLen ;      //  Length
   uint32_t    c_up ;      //  Ascending iterator
   uint32_t    c_down ;    //  Decending iterator
   //  If NULL return
   if (!m_addr)
       return *this ;
   thisCtl = _strXlate(m_addr) ;
   //  Allocate new space
   nLen = thisCtl->_getSize() ;
   destAddr = _strAlloc(nLen) ;
   destCtl = _strXlate(destAddr) ;
   destCtl->_setSize(nLen) ;
   destCtl->m_copy = 1;
   //  Create new string value as the reverse of the original
   c_down = nLen - 1;
   pSrc = thisCtl->_data() ;
   pTgt = destCtl->_data() ;
   for (c_up = 0; c_up < c_down ; c_up++, c_down--)
   {
       pTgt[c_up] = pSrc[c_down] ;
   }
   //  Tidy up
   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 ;
}