Re: [xml] Memory Leak



I assume in all your error handling you return from this subroutine?
 
What version of LibXML are you using?  I use 2.6.x (I don't remember), and have been using it quite a bit (For about 2 years, different versions) and have never encountered a leak in a released version.
 
Also, I assume you only call Cleanup Parser once in your program, right?

Carlo Razzeto <crazzeto comcast net> wrote:

Hello there, I?m rather new to libxml and to this mailing list. I?m writing a Linux daemon in C++ that deals with XML requests and I?m having a problem with memory clean up after parsing my request document. I have flipped through the documentation online but was not able to find anything that helped me out. Here is how my code basically works:

 

xmlDocPtr doc;

xmlNodePtr cur;

 

doc = xmlReadMemory( buffer, byte_count, ?response.xml?, NULL, 0 );

if( doc == NULL ) {

            /* Error handeling */

            Delete( buffer );

            xmlCleanupParser();

}

 

cur = doc->children;

if( cur == NULL ) {

            /* handle error */

            xmlFreeDoc( doc );

            xmlCleanupParser();

            ?..

}

 

cur = cur->children;

if( cur == NULL ) {

            /* handle error */

            xmlFreeNodeList( cur );

            xmlFreeDoc( doc );

            xmlCleanupParser();

            ?..

}

 

While( cur != NULL ) {

            /* process document */

            cur = cur->next;

}

 

delete( buffer );

xmlFreeNodeList( cur );

xmlFreeDoc( doc );

xmlCleanupParser();

xmlCleanupGlobals();

 

return;

 

Thanks for any assistance!

 

Carlo Razzeto

(313) 580-1399

 


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004

_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml


Do you Yahoo!?
Meet the all-new My Yahoo! ? Try it today!

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]