[xml] memory issues when using xmlXPathEvalExpression
- From: "Senthil Nathan" <rsennat gmail com>
- To: xml gnome org
- Subject: [xml] memory issues when using xmlXPathEvalExpression
- Date: Mon, 26 Nov 2007 19:46:40 +0530
Hi All,
I'm having two issues when using libxml and its with my code only.
But please let me know, how to get this fixed.
1. A problem with the memory issue, I guess.
With the below piece of code, in the constructor I have already created a xpathCtx = xmlXPathNewContext(tree);
And then, I have written a xpatheval method, which gets the path to be evaluated.
Because I evaluate the xpath _expression_ in many places, I have written this method.
But with this, sometimes there is a segmentation fault in the xmlXPathEvalExpression( ) call.
(when executing 10 times, twice it gives segv). How can I debug the memory issues with the libxml api's call
or what could be wrong here?
xmlNodeSetPtr OTAccess::OTxmlXPathEvalExpression(string path)
{
const xmlChar* cpath = xmlCharStrdup(path.c_str());
xpathObj = xmlXPathEvalExpression(cpath, xpathCtx);
xmlFree((void*)cpath);
return (xpathObj->nodesetval);
}
2. Another problem is, I wrote a test program which sets the content of an element
But when I used it in my actual code, xmlNodeSetContent(pnode, "
100.100.100.100"), it gives the following error.
Access.cpp:100: error: invalid conversion from 'const char*' to 'const xmlChar*'
Access.cpp:100: error: initializing argument 2 of 'void xmlNodeSetContent(xmlNode*, const xmlChar*)'
Should I need to type cast to const xmlChar*. Even then, how it worked in the test program.
Please help me to fix these problems.
Thanks
Senthil
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]