[gdome]Do I use gdome_di_freeDoc?
- From: "Mr H. Morgan" <hmorgan2 hgmp mrc ac uk>
- To: gdome gnome org
- Subject: [gdome]Do I use gdome_di_freeDoc?
- Date: Mon, 20 Jan 2003 17:36:20 +0000 (GMT)
Hi All,
I am using gdome for generating an xml document. I notice that
gdome_di_freeDoc has been depricated. However, if I do not use this
function, I get more memory left still reachable when the program
finishes (as detected by Valgrind). If I do use this function, I get a
load of errors but less memory still reachable.
I notice the examples still use gdome_di_freeDoc. What is the correct
way to clear the memory used by gdome?
I include a test program I wrote, and some relavent bits of the
valgrind output. More details are avilable at
http://www.hgmp.mrc.ac.uk/~hmorgan2/programming/gdome.html
Thanks for any help,
Hugh Morgan
System -
Red Hat Linux (version 20.x I think, but I could be wrong)
Valgrind 1.9.3
Compiler cc (sorry, I do not know what flavor)
libgdome 0.7.2
Test program -
int main(int argc, char **argv)
{
GdomeDOMImplementation *domimpl = NULL;
GdomeDocument *doc = NULL;
GdomeNode *currentGraphic = NULL;
GdomeNode *currentScene = NULL;
GdomeNode *anotherNode = NULL;
GdomeException exc;
GdomeDOMString *nodeName = NULL;
domimpl = gdome_di_mkref ();
nodeName = gdome_str_mkref_dup("Root");
doc = gdome_di_createDocument(domimpl, NULL, nodeName, NULL, &exc);
currentScene = (GdomeNode *) gdome_doc_documentElement(doc, &exc);
gdome_str_unref (nodeName);
nodeName = gdome_str_mkref_dup("Child");
currentGraphic = (GdomeNode *) gdome_doc_createElement(doc, nodeName,
&exc);
anotherNode = gdome_n_appendChild (currentScene, currentGraphic, &exc);
gdome_str_unref (nodeName);
gdome_n_unref (anotherNode, &exc);
gdome_n_unref (currentGraphic, &exc);
gdome_n_unref (currentScene, &exc);
gdome_di_freeDoc (domimpl, doc, &exc); /* I comment out this line */
gdome_doc_unref (doc, &exc);
gdome_di_unref (domimpl, &exc);
return 0;
}
Valgrind extra bits when you remove gdome_di_freeDoc
==21342== 15 bytes in 3 blocks are still reachable in loss record 1 of 5
==21342== at 0x4015D508: malloc (vg_clientfuncs.c:100)
==21342== by 0x405474B8: xmlStrndup (in /usr/lib/libxml2.so.2.4.23)
==21342== by 0x40547563: xmlStrdup (in /usr/lib/libxml2.so.2.4.23)
==21342== by 0x40557C30: xmlNewDoc (in /usr/lib/libxml2.so.2.4.23)
...
==21342== 80 bytes in 1 blocks are still reachable in loss record 3 of 5
==21342== at 0x4015D508: malloc (vg_clientfuncs.c:100)
==21342== by 0x40557C03: xmlNewDoc (in /usr/lib/libxml2.so.2.4.23)
==21342== by 0x4051451E: gdome_xml_di_createDocument
(gdome-xml-domimpl.c:321)
==21342== by 0x40502739: gdome_di_createDocument (gdome.c:318)
==21342==
==21342== 104 bytes in 2 blocks are still reachable in loss record 4 of 5
==21342== at 0x4015D508: malloc (vg_clientfuncs.c:100)
==21342== by 0x40558EA1: xmlNewNode (in /usr/lib/libxml2.so.2.4.23)
==21342== by 0x40558FC8: xmlNewDocNode (in /usr/lib/libxml2.so.2.4.23)
==21342== by 0x4051238C: gdome_xml_doc_createElement
(gdome-xml-document.c:306)
One paragraph of the error you get with gdome_di_freeDoc present
==5049== Invalid read of size 4
==5049== at 0x40511F7F: gdome_xml_doc_unref (gdome-xml-document.c:177)
==5049== by 0x405043FA: gdome_doc_unref (gdome.c:3230)
==5049== by 0x80488DB: main (iep.c:62)
==5049== by 0x420158D3: __libc_start_main (in /lib/i686/libc-2.2.93.so)
==5049== Address 0x419E3670 is 4 bytes inside a block of size 80 free'd
==5049== at 0x4015D79D: free (vg_clientfuncs.c:182)
==5049== by 0x40557D5E: xmlFreeDoc (in /usr/lib/libxml2.so.2.4.23)
==5049== by 0x405146BC: gdome_xml_di_freeDoc (gdome-xml-domimpl.c:367)
==5049== by 0x405027D5: gdome_di_freeDoc (gdome.c:386)
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]