Re: [xml] returning existing handler in xmlNewCharEncodingHandler

On Tue, Feb 10, 2004 at 07:35:45AM -0500, Daniel Veillard wrote:
On Tue, Feb 10, 2004 at 01:12:02PM +0100, Igor Zlatkovic wrote:
Daniel Veillard wrote:

On Tue, Feb 10, 2004 at 11:50:02AM +0100, oliverst online de wrote:

patch against encoding.c version 1.77 as discussed with Igor on the list


   * Check for existing handler
  handler = xmlFindCharEncodingHandler(name);

  if (handler != NULL)

The patch will change the behaviour of xmlNewCharEncodingHandler(), but 
not that of xmlFindCharEncodingHandler(). The idea was to prevent the 
registration of more than one handler for the same encoding name. That 

  Ah, okay ! I missed that, I'm applying the patch,

  Well, this makes all tests memory leak. Apparently the existing code
relies on the current behaviour. When the default handlers are installed
the new code forces a call to xmlFindCharEncodingHandler() for the
default encodings, this breaks because if iconv is installed then
iconv() handlers are instanciated, and then never freed :-\
  Registering encoding handlers is really a program state, it's better
done at startup. Checking Oliver's initial mail:

: First, you only register a handler, you can't unregister it. It makes
: sense, because as I see from the source there is no
: syncronisation/protection of the handlers, so you can't assure, that
: it's not in use at the moment you would try to free it.

  Right, and handlers can either be static like the predefined ones,
or dynamic (allocated from iconv, which need a context, i.e. an handler
: Another thing is, that you can register several handlers with the same
: name. And when you try to find a specific handler you only get the first
: registered one with the name. Maybe there should be a check to prevent
: more than one handler with the same name.

  Why is this a problem ? If you use iconv you will always get an handler for
a given encoding, unless you registered one yourself for a specific purpose.
This is really a matter of program state, if you have handlers for a given set
of encoding register them at startup, otherwise you will be using iconv ones



Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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