<< Previous | Next >> | |
|
int pool_xinit( Pool_t * p, long base, word nel, word elsize );
Description
- Initialize an xmem memory pool. A pool is a linked list of fixed-size blocks taken from a contiguous area. You can use pools instead of malloc() when fixed-size blocks are all that is needed. You can have several pools, with different size blocks. Using memory pools is very efficient compared with more general functions like malloc(). (There is currently no malloc() implementation with Dynamic C.)
- This function should only be called once, at program startup time, for each pool to be used.
- After calling this function, your application must not change any of the fields in the
Pool_t
structure.Parameters
- p
- Pool handle structure. This is allocated by the caller, but this function will initialize it. Normally, this would be allocated in static memory by declaring a global variable of type
Pool_t
.
- base
- Base address of the xmem data memory area to be managed in this pool. This must be
nel*elsize
bytes long. Typically, this would be an area allocated byxalloc()
when your program starts.
- nel
- Number of elements in the memory area. 1..65535
- elsize
- Size of each element in the memory area. 4..65535
Return value
- Currently always zero. If you define the macro
POOL_DEBUG
, then parameters are checked. If the parameters look bad, then an exception is raised. You can definePOOL_VERBOSE
to getprintf()
messages.Library
- POOL.LIB
See Also
- pool_init, pxalloc, pxcalloc, pxfree, phwm, pavail
Dynamic C Functions | << Previous | Next >> | rabbit.com |