libguac  0.9.10-incubating
Data Structures | Functions
pool.h File Reference

Provides functions and structures for maintaining dynamically allocated and freed pools of integers. More...

Go to the source code of this file.

Data Structures

struct  guac_pool
 A pool of integers. More...
 
struct  guac_pool_int
 Represents a single integer within a larger pool of integers. More...
 

Functions

guac_poolguac_pool_alloc (int size)
 Allocates a new guac_pool having the given minimum size. More...
 
void guac_pool_free (guac_pool *pool)
 Frees the given guac_pool. More...
 
int guac_pool_next_int (guac_pool *pool)
 Returns the next available integer from the given guac_pool. More...
 
void guac_pool_free_int (guac_pool *pool, int value)
 Frees the given integer back into the given guac_pool. More...
 

Detailed Description

Provides functions and structures for maintaining dynamically allocated and freed pools of integers.

Function Documentation

guac_pool* guac_pool_alloc ( int  size)

Allocates a new guac_pool having the given minimum size.

Parameters
sizeThe minimum number of integers which must have been returned by guac_pool_next_int before freed integers (previously used integers) are allowed to be returned.
Returns
A new, empty guac_pool, having the given minimum size.
void guac_pool_free ( guac_pool pool)

Frees the given guac_pool.

Parameters
poolThe guac_pool to free.
void guac_pool_free_int ( guac_pool pool,
int  value 
)

Frees the given integer back into the given guac_pool.

The integer given will be available for future calls to guac_pool_next_int. This operation is threadsafe.

Parameters
poolThe guac_pool to free the given integer into.
valueThe integer which should be returned to the given pool, such that it can be received by a future call to guac_pool_next_int.
int guac_pool_next_int ( guac_pool pool)

Returns the next available integer from the given guac_pool.

All integers returned are non-negative, and are returned in sequences, starting from 0. This operation is threadsafe.

Parameters
poolThe guac_pool to retrieve an integer from.
Returns
The next available integer, which may be either an integer not yet returned by a call to guac_pool_next_int, or an integer which was previously returned, but has since been freed.