# CO_POOL
[COMMON]

common module. More...

Collaboration diagram for CO_POOL:

## Functions
void | co_pool_init (struct co_pool *pool, struct co_pool_hdr *pool_hdr, void *elements, uint32_t elem_size, uint32_t elem_cnt)
| Initialize the pool.
struct co_pool_hdr * | co_pool_alloc (struct co_pool *pool, uint32_t nbelem)
| Allocate elements from the pool.
void | co_pool_free (struct co_pool *pool, struct co_pool_hdr *elements, uint32_t nbelem)
| Release elements from the pool.

## Detailed Description

common module.

## Function Documentation

struct co_pool_hdr* co_pool_alloc | ( | struct co_pool * | pool,
|  | uint32_t | nbelem |
| ) |  |  | `[read]`

Allocate elements from the pool.

Parameters:

  `[in]` | pool | Pointer to the pool from which elements have to be allocated.
  `[in]` | nbelem | Number of elements to allocate from the pool.

Returns:
  Pointer to the list of element(s) allocated from the pool.

Definition at line 67 of file co_pool.c.

References ASSERT_ERR, co_pool::first_ptr, co_pool::freecnt, and co_pool_hdr::next.

void co_pool_free | ( | struct co_pool * | pool,
|  | struct co_pool_hdr * | elements,
|  | uint32_t | nbelem |
| ) |  |  |

Release elements from the pool.

Parameters:

  `[in]` | pool | Pointer to the pool from which the elements are released.
  `[in]` | elements | Pointer to the list of elements that have to be released from the pool.
  `[in]` | nbelem | Number of element to release from the pool.

Definition at line 106 of file co_pool.c.

References ASSERT_ERR, co_pool::first_ptr, co_pool::freecnt, and co_pool_hdr::next.

void co_pool_init | ( | struct co_pool * | pool,
|  | struct co_pool_hdr * | pool_hdr,
|  | void * | elements,
|  | uint32_t | elem_size,
|  | uint32_t | elem_cnt |
| ) |  |  |

Initialize the pool.

During initialization this function is in charge of building the linked lists of elements as well as initializing each element.

Parameters:

  `[in]` | pool | Pointer to the pool.
  `[in]` | pool_hdr | Pointer to the array of pool headers.
  `[in]` | elements | Pointer to the elements' array.
  `[in]` | elem_size | Size of an element belonging to the pool.
  `[in]` | elem_cnt | Number of element belonging to the pool.

Definition at line 34 of file co_pool.c.

References ASSERT_ERR, co_pool_hdr::element, co_pool::first_ptr, co_pool::freecnt, and co_pool_hdr::next.