[Expat-discuss] Expat Embedded

Karl Waclawek karl at waclawek.net
Fri Oct 10 20:38:40 EDT 2003


> I am looking for an XML parser for an embedded device and as occurs with
> every embedded system, I have resource limitations. 
> 
> The device consumes multiple applications (unique process space) and each
> requires XML parsing.
> 
>  
> 
> Any advice on how to instantiate the library in multiple applications, but
> load it just once?
> 
> Is the code re-entrant?

No, it was not a design consideration, as far as I can tell. However,
loading the library only once - that is, the Dll or .so file - should
be OK, as the work is all done through parser instances.
You will need one instance per thread/process.

I have never done this, but I would think that the calls to
XML_ParserCreate/Free are re-entrant.

Also, if you can serialize complete parsing operations, then you
can use the same parser instance multiple times. All you need
to do is re-initialize it with XML_ParserReset for each parse.

> 
> Can I wrap it as a Singleton class?

You could wrap the library in one Singleton class, to manage loading
and unloading the library. But it is important to keep the parser
instances (created by calls to this class) separate for each thread.
In a way this Singleton class is really a factory class.

You could also use this class to serialize access to a single
parser instance, for shared use as described above.

Karl





More information about the Expat-discuss mailing list