![]() |
Home | Libraries | Author | Links |
![]() |
Dpool.
A StmDpool object realizes a concepually unexhausible dynamic pool of elements of a fixed size configured during creation of the pool by stmDpoolCreate().
Out of this pool such elements can be allocated and later be given back. Valid objects of type StmDpool can be achieved only as return values of stmDpoolCreate(). Moreover, variables of type StmDpool may have the value NULL meaning invalid or undefined.
Files | |
file | StmDpoolAdtDoc.h |
Documentation of the abstract structure data type type StmDpool. | |
StmDpool Representation | |
An object of abstract data type StmDpool is represented as a pointer to its implementation. | |
typedef struct StmDpoolImpl_ | StmDpoolImpl_ |
Type name of implementation structure. | |
typedef StmDpoolImpl_ * | StmDpool |
Pointer to implementation. | |
typedef const StmDpoolImpl_ * | ConstStmDpool |
Pointer to constant implementation. | |
StmDpool Creation and Destruction | |
StmDpool | stmDpoolCreate (size_t elsize) |
Creation of a new StmDpool object. | |
void | stmDpoolDestroy (StmDpool dpool) |
Destruction of the StmDpool object dpool. | |
StmDpool Method Functions | |
int | stmDpoolElsize (StmDpool dpool) |
Return the byte length of the elements held by the StmDpool object dpool. | |
int | stmDpoolElcount (StmDpool dpool) |
Return the number of elements currently allocated from the StmDpool object dpool. | |
void * | stmDpoolAllocate (StmDpool dpool) |
Allocate an element from the StmDpool object dpool and return its address. | |
void | stmDpoolFree (void *buf) |
Give the pool element with address buf back to its StmDpool. |
typedef struct StmDpoolImpl_ StmDpoolImpl_ |
typedef StmDpoolImpl_* StmDpool |
typedef const StmDpoolImpl_* ConstStmDpool |
StmDpool stmDpoolCreate | ( | size_t | elsize | ) |
Creation of a new StmDpool object.
[in] | elsize | Fixed byte size of the elements of the StmDpool object. |
NULL
on error. Then the variable errno
contains the error's cause. The StmDpool object created on success.
void stmDpoolDestroy | ( | StmDpool | dpool | ) |
Destruction of the StmDpool object dpool.
[in] | dpool | The StmDpool object to destroy. |
NULL
in which case the function does nothing. int stmDpoolElsize | ( | StmDpool | dpool | ) |
int stmDpoolElcount | ( | StmDpool | dpool | ) |
void* stmDpoolAllocate | ( | StmDpool | dpool | ) |
Allocate an element from the StmDpool object dpool and return its address.
[in] | dpool | The StmDpool object. |
NULL
on error. Then the variable errno
contains the error's cause. The address of the element allocated on success.
void stmDpoolFree | ( | void * | buf | ) |
Give the pool element with address buf back to its StmDpool.
[in] | buf | The address of the pool element to give back. |
NULL
or an address achieved by stmDpoolAllocate(). NULL
address which has not been achieved by stmDpoolAllocate(). Such an error is not detected by the function and results in undefined behaviour. On the other hand it is no error to call the function for the NULL
pointer.
© Copyright Tom Michaelis 2002-2007
Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).