Re: Generic CClosure marshaller using libffi



On Tue, 30 Jan 2007, Behdad Esfahbod wrote:

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

right, where "small" is roughly < 1024 bytes.

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.

we also have g_alloca.

behdad
http://behdad.org/

---
ciaoTJ



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