Re: [PATCH] Add memory buffer length param to SaveToMemory*
Blair Zajac <[email protected]> Sat, 15 Mar 2003 14:23:30 -0800
| Newsgroups | gmane.comp.gnome.gdome |
|---|---|
| Message-ID | <[email protected]> |
Blair Zajac wrote: > > Hello, > > Right now the gdome2 saveDocToMemory and saveDocToMemoryEnc functions > only return to the caller the memory buffer created by libxml2, even > though libxml2 returns the length of that buffer. > > I'm using gmetadom Ocaml bindings (gmetadom uses gdome2) and need to > copy an XSLT generated file from the gmetadom/gdome2 to Ocaml string. > > Right now the Ocaml bindings scan the buffer to find the \0 and then > make another pass to copy the buffer, which is a waste of CPU time. > > The attached patch modifies gdome2 to add an additional int * parameter > to the *saveDocToMemory* calls. Regarding freeing the memory returned by gdome2 (from libxml2 in this case), two thoughts: 1) Provide a free() function that calls the vtable function. 2) Have *saveDocToMemory* return a function pointer to the proper free() to use. The caller saves this pointer until it's needed. If the second method is better, I can modify this patch to do that. Let me know. Best, Blair -- Blair Zajac <[email protected]> Plots of your system's performance - http://www.orcaware.com/orca/