Re: [xml] PATCH: implement xmlSaveToBuffer()



On Mon, Nov 07, 2005 at 11:16:43PM +0100, Geert Jansen wrote:
Daniel Veillard wrote:
Any reason why this couldn't or shouldn't be done the same way 
xmlNewTextWriterMemory is done?
Would only require the addition of write and close callbacks and not 
require any of the other new stuff from the patch.
   

 Right, while Geert patch is correct, an approach where you reuse the
I/O callback to fill up a buffer looks cleaner to me.
 
OK -- please see the attached patch.

  Looks good, just a few comments:

XMLPUBFUN xmlOutputBufferPtr XMLCALL
      xmlOutputBufferCreateBuffer     (xmlBufferPtr buffer,
                                       xmlCharEncodingHandlerPtr encoder);

  A new API but it's not a bad idea, making the link between normal sources
and xmlOutputBuffer / xmlInputBuffer is always confusing new comers to libxml2.

+static int
+xmlBufferClose (void * context) {
+    (void) context;
+    return(0);
+}

  That's absically a noop. I think this can be just removed and NULL be passed
as the function pointer, but to be sure I just removed the 
   (void) context;
line and kept the function declaration, but if you could check that just
removing xmlBufferClose() and passing NULL works that would shave a few
bytes off :-)

   Applied and commited after a bit of cleanup, but this need a bit more testing
before the release.

     Thanks a lot !

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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