server_heap_new()

server_heap_t * server_heap_new(const char *label, int unit_size, int units_per_chunk, int maximum_units, server_heap_options_t options)

Returns a heap pointer for use with the rest of the heap API or NULL on failure.

unit_size specifies how large the individual allocations are to be.

units_per_chunk specifies how many units to grow by whenever heap growth ocurrs. This is the starting value if SERVER_HEAP_GROW_EXPONENTIALLY is set.

The label is a simple name you should use to give this instance some context, most of the SeverKit primitives allow you to name them, this is so when ServerKit reports statistics it can give some meaningful identities to the numbers.

The currently supported options for ServerKit heaps are:

SERVER_HEAP_GROW_EXPONENTIALLY
Grow the heap exponentially, this basically makes the malloc() used for growing double in size every time, starting at the units_per_chunk value you supplied.

SERVER_HEAP_UNLIMITED
Ignore max_units, just keep growing - use this with care or not at all.

SERVER_HEAP_SHRINK
Shrink the heap when it makes sense (this currently is ignored but if you are using a heap where it would make sense to shrink it when possible, specify it, one day libserver will just start doing it.)

Like most options in ServerKit, these are bitwise fields which you may combine by OR-ing them together, or just specify 0 if you don't want to set any options. Most of the time you will probably want to set the exponential growth option, it makes the heap growth more efficient at the cost of some memory... but it really depends on what you need. The shrinking option is currently not implemented but should still be specified where desired.

2007-12-06