From 7a9033fb2d2057dc8104d9b6f22c94e83e36f8ce Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 5 Jan 2008 18:26:54 +0100 Subject: 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 (This used to be commit 60ef9a84f0bd18d48e453c08aa420d17275e0881) --- source4/lib/talloc/talloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/talloc/talloc.h') diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index e103391681..5431971655 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -116,6 +116,7 @@ typedef void TALLOC_CTX; /* The following definitions come from talloc.c */ void *_talloc(const void *context, size_t size); +void *talloc_pool(const void *context, size_t size); void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)); int talloc_increase_ref_count(const void *ptr); size_t talloc_reference_count(const void *ptr); -- cgit