Removes trailing whitespace Arguments: None

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

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

Function Logic:

0:START 1:unknown 2:Return *this 3:thisCtl i nLen wc 4:unknown 5:unknown 6:items 7:unknown 8:Return *this 9:nLen 10:nusize 11:unknown 12:items 13:Return *this 14:destAddr 15:unknown 16:items 17:destCtl items items destCtl 18:unknown 19:unknown 20:items 21:unknown 22:items 23:unknown 24:items 25:m_addr 26:Return *this

Function body:

hzString& hzString::DelWhiteTrail (void)
{
   //  Removes trailing whitespace
   //  
   //  Arguments: None
   //  Returns: Reference to this string in all cases
   _hzfunc("hzString::DelWhiteTrail") ;
   _strItem*       thisCtl ;   //  This string's control area
   _strItem*       destCtl ;   //  New string space
   const char*     i ;         //  Pointer into string data
   uint32_t        destAddr ;  //  New string address if required
   uint32_t        wc ;        //  Count of whitespace chars
   uint32_t        nLen ;      //  Length of original string
   uint32_t        nusize ;    //  The size the string will be once leading whitespace removed
   int32_t         count ;     //  Iterator
   if (!m_addr)
       return *this ;
   thisCtl = _strXlate(m_addr) ;
   i = (char*) thisCtl->_data() ;
   nLen = Length() ;
   wc = 0;
   for (count = nLen - 1; count >&eq; 0; count--)
   {
       if (i[count] <&eq; CHAR_SPACE)
           wc++ ;
       else
           break ;
   }
   if (!wc)
       return *this ;
   //  Must alter content
   nusize = nLen - wc ;
   if (nusize <&eq; 0)
   {
       Clear() ;
       return *this ;
   }
   destAddr = _strAlloc(nusize) ;
   if (!destAddr)
       hzexit(E_MEMORY, "Buffer of (%d) bytes", nusize) ;
   destCtl = _strXlate(destAddr) ;
   destCtl->_setSize(nusize) ;
   memcpy(destCtl->_data(), thisCtl->_data(), nusize) ;
   destCtl->m_copy = 1;
   //  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 ;
}