开发者

does XMLDOMNodePtr::get_text() needs to be deallocated explicitly?

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;
  开发者_JAVA技巧  /*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.


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;
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜