Set a string to a non-terminated char string
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzString::SetValue | (const char*,uint32_t,) |
Declared in file: hzString.h
Defined in file : hzString.cpp
Function Logic:
Function body:
hzEcode hzString::SetValue (const char* cpStr)uint32_t nLen,
{
// Set a string to a non-terminated char string
//
// Arguments: 1) cpStr The char* pointer
// 2) nLen The length
//
// Returns: E_OK If operation successful
// E_RANGE If length is -ve or too uint32_t
_hzfunc("hzString::SetValue(a)") ;
_strItem* destCtl ; // New string space
Clear() ;
if (!cpStr || !cpStr[0])
return E_OK ;
if (nLen <&eq; 0|| nLen > HZSTRING_MAXLEN)
{
operator=(_hzString_TooLong) ;
return E_RANGE ;
}
m_addr = _strAlloc(nLen) ;
if (!m_addr)
hzexit(E_MEMORY, "Cannot allocate string of %d bytes", nLen) ;
destCtl = _strXlate(m_addr) ;
destCtl->_setSize(nLen) ;
memcpy(destCtl->_data(), cpStr, nLen) ;
destCtl->m_copy = 1;
return E_OK ;
}