Re: [patch] calling g_malloc & co via a vtable



Hi Alexander,

> > > And, optionally, if the maintainers think it's suitable:
> > > * Add a memory pressure callback. With suitable comments in the code
> > >   explaining the problems this can cause if used improperly ("Here be
> > >   dragons")
> >
> > I don't think you can have a generic one (people have to keep up with
> > their own list of stuff they can free). Or if you mean just a function
> > to be called by the default malloc(), I think it's better to just let
> > people replace the default malloc.
> 
> I was thinking more of a list of callbacks that the default g_malloc
> called when malloc returns NULL, but i'm comfortable with not having this
> at all.

Those callbacks are not possible, because of g_realloc (see my other post)

And further: The vtable must be set at most once and before any allocation
takes place. Thats obvoius, I think. Now take a C++-program with global
objects, which on construction call g_malloc. Then these objects call the
standard g_malloc, while everything after the setting of the vtable in main
calls your version: Bummer. 

Bye,
Sebastian
-- 
Sebastian Wilhelmi                   |            här ovanför alla molnen
mailto:wilhelmi ira uka de           |     är himmlen så förunderligt blå
http://goethe.ira.uka.de/~wilhelmi   |




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