Return Type | Function name | Arguments |
---|---|---|
hzString& | hzString::DelWhiteLead | (void) |
Declared in file: hzString.h
Defined in file : hzString.cpp
Function Logic:
Function body:
hzString& hzString::DelWhiteLead (void) { _hzfunc("hzString::DelWhiteLead") ; _strItem* thisCtl ; _strItem* destCtl ; const char* i ; uint32_t destAddr ; uint32_t wc ; uint32_t count ; uint32_t nLen ; uint32_t nusize ; if (!m_addr) return *this ; thisCtl = (_strItem*) _strXlate(m_addr) ; nLen = Length() ; i = (char*) thisCtl->_data() ; for (wc = count = 0; count < nLen ; count++) { if (i[count] <&eq; CHAR_SPACE) wc++ ; else break ; } if (!wc) return *this ; nusize = nLen - wc ; if (nusize <&eq; 0) { Clear() ; return *this ; } destAddr = _strAlloc(nusize) ; if (!destAddr) hzexit(E_MEMORY, "Buffer of (%d) bytes", nusize) ; destCtl = (_strItem*) _strXlate(destAddr) ; destCtl->_setSize(nusize) ; memcpy(destCtl->_data(), thisCtl->_data() + wc, nusize) ; 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 ; }