Return Type | Function name | Arguments |
---|---|---|
hzString& | hzString::TruncateBeyond | (const char*,) |
Declared in file: hzString.h
Defined in file : hzString.cpp
Function Logic:
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 ; }