Re: [gtk-list] Re: Bug with GMemChunk



Tim Janik <timj@gtk.org> writes:

> the third argument here should be SIZE*16 if you want 16 atoms preallocated,
> since each atom is actually 4096 bytes in size (and not sizeof(guint8)==1).
> you can also use the more convenient wraper macro g_mem_chunk_create(),
> where you just pass in the real type that you are allocating, with
> that you'd write:

Thanks for the explanation. 

But then I do not understand why gtree.c (which is where I got my code
from) has

        node_mem_chunk = g_mem_chunk_new ("GLib GTreeNode mem chunk",
                                          sizeof (GTreeNode),
                                          1024,
                                          G_ALLOC_ONLY);

and not e.g.

        node_mem_chunk = g_mem_chunk_new ("GLib GTreeNode mem chunk",
                                          sizeof (GTreeNode),
                                          64*sizeof (GTreeNode),
                                          G_ALLOC_ONLY);

It seems at best unclear, at worst wrong


Søren Sandmann



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