Re: [xml] [htmlParser] The right way to free a htmlParserCtxtPtr

Le mardi 02 novembre 2004 à 03:52 -0500, Daniel Veillard a écrit :

Hi daniel,


htmlParserCtxtPtr ctxt = NULL;

ctxt = htmlCreateMemoryParserCtxt (buffer, strlen (buffer));
htmlParseDocument (ctxt);

htmlFreeParserCtxt (ctxt);

  that's fine.

Strange. I have a huge occupation of the memory using this. But it seems
to be ok when I use manually "xmlFreeDoc ()" on "ctxt->myDoc" after
calling "htmlFreeParserCtxt ()".

But browing the libxml2 source code I saw that there is a "htmlCtxtReset
()" that seems to really freeing all stuff (including "ctxt->myDoc").
Should I call this function just before calling "htmlFreeParserCtxt ()"?

  This should be used only if you want to parse a collection of html
document with the same context, then the reset call should be used between
2 parses.

I have a segfault using that function instead of "htmlFreeParserCtxt ()"
between to checks.

Thanks for those informations,


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