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 confused that is it necessary to do SysFreeString here?
and anyone can help me?
thanks!