24 See \fB\\$1\fP for details.
27 See \fB\\$1\fP in \fB\\$2\fP for details.
31 pool_alloc, pool_free, pool_talloc, pool_tfree, pool_create, pool_destroy
32 \- Allocate and free memory in managed allocation pools.
34 .B #include "pool_alloc.h"
36 \fBstruct alloc_pool *pool_create(size_t \fIsize\fB, size_t \fIquantum\fB, void (*\fIbomb\fB)(char *), int \fIflags\fB);
38 \fBvoid pool_destroy(struct alloc_pool *\fIpool\fB);
40 \fBvoid *pool_alloc(struct alloc_pool *\fIpool\fB, size_t \fIsize\fB, char *\fImsg\fB);
42 \fBvoid pool_free(struct alloc_pool *\fIpool\fB, sise_t \fIsize\fB, void *\fIaddr\fB);
44 \fBvoid *pool_talloc(struct alloc_pool *\fIpool\fB, \fItype\fB), int \fIcount\fB, char *\fImsg\fB);
46 \fBvoid pool_tfree(struct alloc_pool *\fIpool\fB, \fItype\fB, int \fIcount\fB, void *\fIaddr\fB);
49 The pool allocation routines use
51 for underlying memory management.
52 What allocation pools do is cause
53 memory within a given pool to be in large contigious blocks
54 (called extents) that when freed will be reusable. Unlike
56 the allocations are not managed individually.
57 Instead each extent tracks the total free memory within the
58 extent. Each extent can either be used to allocate memory
59 or to manage the freeing of memory within that extent.
60 When an extent has less free memory than a given
61 allocation request or when the first request to free
62 memory within that extent is received the extent ceases to
63 be used for allocation.
65 This form of memory management is suited to large numbers of small
66 related allocations that are held for a while
67 and then freed as a group.
69 underlying allocations are done in large contigious extents
70 when an extent is freed it releases a large enough
71 contigious block of memory to be useful to subsequent
75 calls even if allocations from other pools or from
77 are made between allocations from a given pool.
80 Creates an allocation pool for subsequent calls to the pool
82 When an extent is created for allocations it will be
85 Allocations from the pool have their sizes rounded up to a
93 Will produce a quantum that should meet maximal allignment
98 is set allocations will be aligned to addresses that are a
104 is set all allocations from the pool will be zero filled.
107 destroys an allocation pool and frees all memory allocated
113 bytes from the specified
121 If the requested memory cannot be allocated
125 function, if defined, with
127 as it's sole argument and
136 previously allocated in the specified
138 The memory freed within an extent will not be reusable until
139 all of the memory in that extent has been freed but
140 depending on the order in which the
141 allocations are freed some extents may be released for reuse
142 while others are still in use.
153 no memory will be freed but subsequent allocations will come
157 is a macro that take a
163 and will cast the return value to the correct type.
166 is a macro to free memory previously allocated in the
172 .BR "struct alloc_pool" .
177 return pointers to the allocated memory,
178 or NULL if the request fails.
179 For each extent so long as no allocations are smaller than varaible
180 allignment requirements this pointer will be suitably
181 alligned for any kind of variable.
184 will normally require casting to the desired type but
186 will returns a pointer of the requested
198 pool_alloc was created by J.W. Schultz of Pegasystems Technologies.