Re: Use of Memory Slices in N-ary Trees



Hello.

> Ok I understand that its using g_slice_new0, but does this mean that it does
> it just for a single GNode, one at a time?
> What I was after was more like say being able to allocate 100 such GNodes at
> a time upfront if I had a tree with say 5000 nodes in it or something, so I
> am able to get a whole chunk of GNodes at the one time!
> Maybe I am misunderstanding something?

It does allocates single node when calling g_node_new() and there is
no way to preallocate memory. But you should not need this, since
slice allocator takes care of making sure memory is allocated
efficiently (if you're interested in this magic, have a look at
glib/gslice.[ch] in git repo).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com


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