views:

26

answers:

1

Greetings,

Would like to know if we need to explicitly free the string allocated by a xmldomnodeptr using it's get_text()

i.e.

    IXMLDOMNodePtr pNode;
    /*some code*/
    BSTR sValue;
    pNode->get_text(&sValue);
    /*Should I do this?*/
    SysFreeString(sValue);

I cannot see any documentation stating the same, so I'm assuming we need to do explicit deallocation sysfreestring. But, Just need to be double sure :)

Thanks in advance.

Samrat Patil.

+1  A: 

yes. You will have to free the string.

BSTR bstrItemText = NULL;
pIDOMNode->get_text(&bstrItemText); //Discl: return value is not checked here...
if(bstrItemText)
 {
     ::SysFreeString(bstrItemText);
     bstrItemText = NULL;
 }
aJ
Thank you very much!
Samrat Patil