libguac
1.6.0
|
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_pool * | guac_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... | |
int | guac_pool_next_int_below (guac_pool *pool, int limit) |
Returns the next available integer from the given guac_pool that is below the given limit. More... | |
int | guac_pool_next_int_below_or_die (guac_pool *pool, int limit) |
Returns the next available integer from the given guac_pool that is below the given limit. More... | |
void | guac_pool_free_int (guac_pool *pool, int value) |
Frees the given integer back into the given guac_pool. More... | |
Provides functions and structures for maintaining dynamically allocated and freed pools of integers.
guac_pool* guac_pool_alloc | ( | int | size | ) |
void guac_pool_free | ( | guac_pool * | pool | ) |
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 atomic.
pool | The guac_pool to free the given integer into. |
value | The 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 sequence, starting from 0. This operation is atomic.
pool | The guac_pool to retrieve an integer from. |
int guac_pool_next_int_below | ( | guac_pool * | pool, |
int | limit | ||
) |
Returns the next available integer from the given guac_pool that is below the given limit.
If no such integer can be obtained because all such integers are already in use, -1 will be returned instead. All integers successfully returned are non-negative, and are returned in sequence, starting from 0. This operation is atomic.
pool | The guac_pool to retrieve an integer from. |
limit | The exclusive upper bound to enforce on all integers returned by this function. Integers of this value or greater will never be returned. If all other integers are already in use, -1 will be returned instead. |
int guac_pool_next_int_below_or_die | ( | guac_pool * | pool, |
int | limit | ||
) |
Returns the next available integer from the given guac_pool that is below the given limit.
If no such integer can be obtained because all such integers are already in use, the current process will abort and this function will not return. All integers successfully returned are non-negative, and are returned in sequence, starting from 0. This operation is atomic.
pool | The guac_pool to retrieve an integer from. |
limit | The exclusive upper bound to enforce on all integers returned by this function. Integers of this value or greater will never be returned. If all other integers are already in use, the current process will abort and this function will not return. |