From 4e091eb81e7a5ada5d8aafa7990d094f276f2099 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Wed, 27 Feb 2013 04:40:09 +0000 Subject: Fix handling of encoding change --- examples/libxml.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/libxml.c b/examples/libxml.c index 1e787e2..e970e4c 100644 --- a/examples/libxml.c +++ b/examples/libxml.c @@ -213,19 +213,20 @@ int main(int argc, char **argv) * change_encoding() will have put the new charset into * c->encoding. */ - hubbub_parser *temp; + context *c2; - if (hubbub_parser_create(c->encoding, true, myrealloc, NULL, - &temp) != HUBBUB_OK) { - destroy_context(c); + error = create_context(c->encoding, &c2); + if (error != OK) { + destroy_context(c2); free(buf); fclose(input); - fprintf(stderr, "Failed recreating parser\n"); + fprintf(stderr, "Failed recreating context\n"); return 1; } - hubbub_parser_destroy(c->parser); - c->parser = temp; + destroy_context(c); + + c = c2; /* Retry the parse */ error = parse_chunk(c, buf, len); -- cgit v1.2.3