[xml] Memory Leak



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



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