Clear this string. The end result will be this string has a null pointer and the string space that was being pointed to, has its copy count reduced by 1. If this means the copy count falls to zero, then the string space shall be freed. Clears the string. Note that if other string instances share the same internal string space (have equal contents) then all that occurs is a decrement of the copy count. This leaves the string value intact maintaining the integrity of the other string instances. Only if there are no other string instances sharing the internal string space (copy count is zero) is the internal string space is released (deleted). In both cases the local internal string space pointer is then set to null. Subsequent setting of this hzString instance will then allocate fresh memory. Arguments: None Returns: None

Return TypeFunction nameArguments
voidhzString::Clear(void)

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

Function Logic:

0:START 1:unknown 2:thisCtl nLen 3:unknown 4:items 5:unknown 6:items m_addr 7: No text 8:unknown 9:unknown 10:items 11:m_addr 12: No text

Function body:

void hzString::Clear (void)
{
   //  Clear this string.
   //  
   //  The end result will be this string has a null pointer and the string space that was being pointed to, has its copy count reduced by 1. If this means the
   //  copy count falls to zero, then the string space shall be freed.
   //  
   //  Clears the string. Note that if other string instances share the same internal string space (have equal contents) then all that occurs is a decrement of
   //  the copy count. This leaves the string value intact maintaining the integrity of the other string instances. Only if there are no other string instances
   //  sharing the internal string space (copy count is zero) is the internal string space is released (deleted). In both cases the local internal string space
   //  pointer is then set to null. Subsequent setting of this hzString instance will then allocate fresh memory.
   //  
   //  Arguments: None
   //  Returns: None
   _hzfunc("hzString::Clear()") ;
   _strItem*   thisCtl ;       //  This string's control area
   uint32_t    nLen ;          //  Length of string
   if (m_addr)
   {
       thisCtl = _strXlate(m_addr) ;
       nLen = thisCtl->_getSize() ;
       if (!nLen)
           hzexit(E_CORRUPT, "Zero string size %u:%u", (m_addr&0xffff0000)>>16,m_addr&0xffff);
       if (thisCtl->m_copy == 0)
       {
           printf("WARN - Zero copis of string size %u:%u (%s)", (m_addr&0xffff0000)>>16,m_addr&0xffff,thisCtl->_data());
           m_addr = 0;
           return ;
       }
       if (thisCtl->m_copy && thisCtl->m_copy < 50)
       {
           if (__sync_add_and_fetch(&(thisCtl->m_copy), -1)== 0)
               _strFree(m_addr, nLen) ;
       }
       m_addr = 0;
   }
}