Implement talloc_pool()
authorVolker Lendecke <vl@samba.org>
Sat, 5 Jan 2008 17:26:54 +0000 (18:26 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 10 Jan 2008 01:05:19 +0000 (17:05 -0800)
commit287e29d988813007eeebc0c2bef3b46ab8bedee9
treef9163e44f2d7b54216052c0f7cb39b1617c609bd
parent92fcf22b79809393c734e4005c34a5e7e4aaa912
Implement talloc_pool()

A talloc pool is a chunk of memory that can be used as a context for further
talloc calls. Allocations with the pool as the parent just chew from that
memory by incrementing a pointer. If the talloc pool is full, then we fall back
to the normal system-level malloc(3) to get memory.

The use case for talloc pools is the transient memory that is used for handling
a single SMB request. Incrementing a pointer will be way faster than any malloc
implementation.

There is a downside of this: If you use talloc_steal() to move something out of
the pool, the whole pool memory is kept around until the last object inside the
pool is freed. So if you talloc_free() the pool, it might happen that the
memory is freed later. So don't hang anything off a talloc pool that should
live long.

Volker
source/lib/talloc/talloc.c
source/lib/talloc/talloc.h
source/lib/talloc/testsuite.c