Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
virtual P6R::P6ERR P6R::p6ISafeString::setMemSecure ( P6VOID pMemory,
P6INT  nValue,
P6SIZE  nBytes 
)
pure virtual

Set the specified number of bytes in pMemory to nValue.

This method has been designed so that standards compliant compilers won't optimize away writes to the destination if the destination is never used (as would be the case with a compiler implementing dead code detection).

Here's an example of a case that could potentially be optimized away when not using the "non-secure" form of this method:

* void somefunc(p6ISafeString *pStr)
* {
* P6CHAR szPasswd[MAXPASSWD];
*
* getUserPasswd(szPasswd,P6CHARCNT(szUserPasswd);
* useThePassword(szPasswd);
* pStr->setMem(szPasswd,sizeof(szPasswd));
* }
*
* In this case the purpose of calling setMem() in this situation is to
* clear the password buffer so that the password cannot be recovered from
* from memory later. However, the compiler may optimize away that call
* since the memory is never referenced again.
*
*
Parameters
pMemory[ in ] Pointer to the destination buffer.
nValue[ in ] The value to set.
nBytes[ in ] The number of bytes in pMemory to set to nValue.
Returns
SuccessP6R::eOk 
FailureP6R::eInvalidArgpMemory is NULL or nBytes is zero.