Re: [xml] xmlReadFile(...) crashing on 2nd time around





Thank you Martin, that works.

However, I am intrigued to know why this causes an issue.

My program consists of:

   (1)  Main program is written in Borland C++ v5.01
   (2)  Regular MFC DLL

The program in (1) loads the DLL in (2) by calling LoadLibrary etc... the
DLL has Libxml2 statically linked.

The program (1) called loaded and unloaded the DLL in (2) which in turn
loaded an XML with Libxml2.  With the call into xmlCleanupParser() the 1st
call to the DLL was OK but if the program loaded the DLL again in the same
session a crash resulted.  Now that I have taken out the call into
xmlCleanupParser() I no longer get the crash.

I would appreciate if anyone can let me know why I no longer get the crash. 
Do I need to call anything other than xmlCleanupParser().  Of course I am
freeing the xmlDocPtr and contexts correctly.


Martin (gzlist) wrote:

On 10/12/2009, Andrew Hartley <andrew hartley bcs org uk> wrote:

This is my code to read an XML file, which works fine the 1st time
around,
but crashes the 2nd time around.  I must be not calling a required
library
function to tidy up and would appreciate if someone could advise on what
I
should do.

...

     xmlCleanupParser();

Remove that from your destructor.

<http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser>

"This function name is somewhat misleading. It does not clean up
parser state, it cleans up memory allocated by the library itself"

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



-- 
View this message in context: 
http://old.nabble.com/xmlReadFile%28...%29-crashing-on-2nd-time-around-tp26731653p26779993.html
Sent from the Gnome - Lib - Xml - General mailing list archive at Nabble.com.




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