Re: Generic CClosure marshaller using libffi

On Tue, 2007-01-30 at 18:13 -0200, Johan Dahlin wrote:
> > On Tue, 2007-01-30 at 08:22 -0500, Johan Dahlin wrote:
> >> +  atypes = g_new (ffi_type *, n_args);
> >> +  args =  g_new (gpointer, n_args); 
> > 
> > How about using gslice?
> > 
> Does it really make sense to use GSlice when allocating an array of
> pointers? I thought it was mostly useful to allocate an array of
> structures.

It makes sense to use gslice for all small allocations IMO.  For things
like your usecase that you are freeing the memory very very soon, there
may not be any memory fragmentation worries.  So the benefit of gslice
here would be speed on systems that have a slow malloc.

Thinking about it now, better would be to use a stack buffer for small
n_args values, like 8 for example.


"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

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