Re: [xml] calling xmlCleanupParser from a library considered harmful



On Tue, Oct 30, 2012 at 07:12:41AM +0000, Alex Bligh wrote:

On 30 Oct 2012, at 02:07, Daniel Veillard wrote:

Opinions about this ?

One issue is that for library authors there is no safe way of making
your library not introduce reported valgrind leakage into the calling
program.

Could you add 1 to a counter on xmlInit() and decrement it on
xmlCleanupParser(), and only do anything if xmlCleanupParser hits
zero.

  Unfortunately that's unikey to ever work well, libxml2 doesn't force
xmlInit() or other init routines and call them internally on most
document parse paths to make sure there is initialization even if
the user code didn't call it.

I think this is safe in that all you'd do is memory leak if the
app or the library didn't pair their statements. You could have a

  I think it so safe it would not even run the cleanup on something
like xmllint.

xmlImNotALibrarySoForceCleanupParser() or similar for the main
program.

  That's another way, yes, empty the old function and create a new one.

Daniel


-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/



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