Re: g_slice_



On Sat, 3 Dec 2005, Dave Benson wrote:

On Sat, Dec 03, 2005 at 10:35:38PM -0500, Behdad Esfahbod wrote:
On Sat, 3 Dec 2005, Morten Welinder wrote:

I might be dense, but what exactly does g_slice_ buy us over
plain, old malloc?

* Don't say speed.  That's a bogus argument because you cannot
  possibly have tested all mallocs.

It's tested with the glibc implementation, and that buys us speed
over the malloc at hand.

i have two sort-of related questions:
 - doesn't this belong in glibc?

i guess you could submit this to the glibc team and figure their reaction.

 - why isn't it implemented as g_mem_set_table(g_slice_allocator)?

because g_slice has a different API than malloc.
most importantly, you provide the chunk size with alloc and with free,
which allows the allocator to behave differently depending on the chunk
size. the system malloc/free can't do that without attaching boundary
tags to every piece of memory handed out, which contains its size.


- dave

---
ciaoTJ



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