GMemChunk for skip lists



     Hello,
	I'm trying to figure out how to use Glib's faster memory
management for my Glib-styled skip list implementation.  Right now I'm
calling g_malloc() and g_free() for each individual element.

	I noticed that GMemChunk only allows for equally-sized elements.
This is a problem for skip lists, because your elements all have different
sizes (a size for every Node in the set 1..max_height).  This is because
skip lists use a variable-sized array as the last element of the Node
struct.

	Any suggestions?

	One I idea I had was to have one GMemChunk for every possible
level in the skip list.  max_height is usually 16 or less, but in
practical terms should probably never be more than 32.  So generally
that'd be 16 different GMemChunks for a single skip list.  When I allocate
a new Node, I'd just use the GMemChuck for that level.  Does this make
sense?  Any other suggestions?

	Also, what is the point of a GAllocator?


Thank You,
Derek Simkowiak
dereks@kd-dev.com



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