NAME

pool_create, pool_destroy, pool_alloc, pool_free
- memory allocation

SYNOPSIS

#include <sys.h>

int pool_create( int poolno,
unsigned long startaddr , unsigned long endaddr );
int pool_destroy( int poolno );
void *pool_alloc( int poolno , size_t size );
int pool_free( int poolno , void *buf );

pool_alloc() and pool_free() are callable from an ISR.

DESCRIPTION

Memory pools are used for dynamic allocation of variable size buffers. Up to 8 memory pools may be created. Valid poolno values are 0 through 7 inclusive.

A memory pool is created with a call to pool_create(). startaddr and endaddr indicated the pool limits. It is up to the caller to provide a contiguous block of memory for the memory pool. poolno is a handle which will be used to access the pool. Memory pool poolno can be destroyed with a call to pool_destroy. pool_alloc returns a pointer to a dynamically allocated block of size bytes from memory pool poolno. pool_free returns the block of memory, allocated with a call to pool_alloc, to memory pool poolno.

RETURN VALUES

pool_create() and pool_destroy() return 0 if sucessfull. If they fail, they set errno and return -1.

pool_alloc() returns 0 on failure and a pointer to the allocated buffer if successfull.

ERRORS

pool_create() will set the following errors:

EINVAL
poolno is not in the range 0 to 7 or is already in use.

pool_destroy() will set the following errors:

EINVAL
poolno is not in the range 0 to 7 or has outstanding memory allocated.

SEE ALSO

pt_create()




< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2008 >