|
-
May 19th, 1999, 04:51 PM
#1
SysFreeString() WHEN???
We've a discussion and a potential problem:
We've a server that is a client to a DCOM component. The server has a GetName([out] BSTR * bname) method:
We've been calling with the following:
BSTR bname = NULL;
IDbSrv * pdb;
CoCreateInstanceEx( GUID, &pdb); ...
pdb->GetName( &bname );
SysFreeString( bname); // Is this required???
We're worried about global leaks if not freeing the string.
in IDL:
Library ...
class IDbSrv
{
HRESULT GetName( [out] BSTR * bname );
}
in the server
CIDbSrv::GetName( BSTR * bname )
{
CComVariant var;
CString name;
HRESULT hr = S_FALSE;
if ( protecteddb.GetName( name ) )
{
var = name;
*bname = var.bstrVal;
hr = S_OK;
}
return hr;
}
One says that BSTR is NOT necessary as C++ will clean it up, another says it MUST be SysFree'd.
Accurate input or guidance with this POORLY documented BSTR would be appreciated to prevent LEAKING and double frees.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|