| Return Type | Function name | Arguments |
|---|---|---|
| hzString& | hzString::Truncate | (unsigned int,) |
Declared in file: hzString.h
Defined in file : hzString.cpp
Function Logic:
Function body:
hzString& hzString::Truncate (unsigned int limit)
{
_hzfunc("hzString::Truncate") ;
_strItem* thisCtl ;
_strItem* destCtl ;
uint32_t destAddr = 0;
if (!m_addr)
return *this ;
thisCtl = (_strItem*) _strXlate(m_addr) ;
if (limit >&eq; thisCtl->_getSize())
return *this ;
if (limit)
{
destAddr = _strAlloc(limit) ;
destCtl = (_strItem*) _strXlate(destAddr) ;
destCtl->_setSize(limit) ;
memcpy(destCtl->_data(), thisCtl->_data(), limit) ;
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 ;
}