Home > Archive > VC Language > June 2005 > should i do SysFreeString here?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
should i do SysFreeString here?
|
|
|
| i'm just doing some wrap class for msxml and got some problem?
i'm using the raw interface in msxml.h, not smart pointer. (visual studio
2003)
sample code like this:
//--start-------------------------------------------
{
IXMLDOMDocument* pDoc = NULL;
HRESULT hr = ::CoCreateInstance(CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**) &pDoc);
hr = pDoc->put_async(VARIANT_FALSE);
hr = pDoc->put_validateOnParse(VARIANT_FALSE);
hr = pDoc->put_resolveExternals(VARIANT_FALSE);
CComVariant varFile(_T("c:\\aa.xml"));
VARIANT_BOOL status;
hr = pDoc->load(varFile, &status);
BSTR bstrXML = NULL;
pDoc->get_xml(&bstrXML);
//***********************
// doing some processing for bstrXML;
// ...
//
SysFreeString(bstrXML); //should i do SysFreeString here?
//***********************
pDoc->Release();
}
//--end---------------------------------------------
i have used _CrtDumpMemoryLeaks() and
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF )
to detect memory leak.
but whether i do SysFreeString or not, there is no memory leak detected.
i believe use SysFreeString() here is a good behave.
and i have viewed some code from others. someone use, someone not.
i am very that is it necessary to do SysFreeString here?
and anyone can help me?
thanks!
| |
| Jeff Partch [MVP] 2005-06-02, 4:02 am |
| "aotin" <aotin@discussions.microsoft.com> wrote in message
news:3855E3CA-B224-48EB-8419-8584DA6165E9@microsoft.com...
>
> BSTR bstrXML = NULL;
> pDoc->get_xml(&bstrXML);
>
> //***********************
> // doing some processing for bstrXML;
> // ...
> //
> SysFreeString(bstrXML); //should i do SysFreeString here?
Yes.
--
Jeff Partch [VC++ MVP]
|
|
|
|
|