Re: [xml] context reuse for push parser

On Tue, Oct 21, 2003 at 05:58:45PM -0400, Daniel Veillard wrote:
On Tue, Oct 21, 2003 at 10:19:43PM +0100, Graham Bennett wrote:
Hi all,

I added the following function to enable me to reuse the parser context
using the push parser.  It corresponds to xmlCreatePushParserCtxt, but
takes an existing context.  Not sure if it's generally useful but it
seems to work for my code.

  Okay might make a good addition to the new parser interfaces.

[ snip ]

  if (ctxt == NULL) {
    xmlErrMemory(NULL, "No parser context\n");

  Hum, this isn't really a memory error. It's an API use error, I would rather
make the function return 0 in case of success and -1 in case of error, and
return -1 in that case (and check on function entry).

Yep sounds better.  I'm sure a lot of it needs to be cleaned up, I just
did the bare minimum to get it working.


  ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 * sizeof(xmlChar

  Hum, you're likely to memleak there. ctxt->pushTab is probably not NULL,

Oops yes, that's wrong :)

[ snip ]

  if (enc != XML_CHAR_ENCODING_NONE) {
    xmlSwitchEncoding(ctxt, enc);

  maybe an extra encoding passed as a const char * is needed. C.f. 
section F.2. of the spec:
in that case the context encoding overrides the one fine in the XML
declaration or autodetected by xmlDetectCharEncoding() which implement
the F.1. detection algorithm.
Sounds reasonable.  In my case I think I'd always want to autodetect it,
but still it would be useful.

  it's a good idea, that could be reused within the xmlreader code.

Ok cool.



Graham Bennett

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