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

Set the entire contents of a P6BSTR 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)
* {
* P6UCHAR szBuffer[MAXPASS];
* P6BSTR bsPasswd = {&szBuffer,MAXPASS};
*
* getUserPasswd(&bsPasswd);
* useThePassword(&bsPasswd);
* pStr->bstrSetMem(bsPasswd,0);
* }
*
* In this case the purpose of calling bstrSetMem() 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 P6BSTR.
nValue[ in ] The value to set.
Returns
SuccessP6R::eOk 
FailureP6R::eInvalidArgpMemory or pMemory->pString is NULL .