Re: [gdome]Re: [Gmetadom-ocamldev] Gdome providing free()



On Sun, 2003-03-16 at 00:50, Blair Zajac wrote:
> I'm not too certain about that, but maybe I'm missing something.
> 
> Here's gdome_di_saveDocToMemory:
> 
> GdomeBoolean
> gdome_di_saveDocToMemory (GdomeDOMImplementation *self, GdomeDocument *doc,
> char **mem, int *mem_length, GdomeSavingCode mode, GdomeException *exc)

yes you are right. So I believe this is basically the only case in the
whole Gdome2 library where this happens, together with
saveDocToMemoryEnv.

I'm not keen on making extensive changes in the memory management just because
of a non-standard, isolated method. But I think there is a better way to fix
this, for which I don't see other bad side-effects. If, instead of returning
a char*, we make the method return a GdomeDOMString* (which has to be
properly allocated from inside Gdome2), then GdomeDOMString will correctly
invoke xmlFree when the last reference to it is gone. GdomeDOMString has a
mechanism similar to that described by you, so that a hidden callback function
is invoke upon destruction of the string (see gdome-xml-str.c for details).

What about it?

-- luca





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