# COMMON
[MACSW]

Module grouping the general purpose SW tools. More...

Collaboration diagram for COMMON:

## Data Structures
struct | co_pool_hdr
| Generic descriptor header of a pool element. More...
struct | co_pool
| Structure containing the pool's information: free list pointer and remaining number of elements available. More...
## Modules
| CO_DLIST

| Double linked list management.
| CO_ENDIAN

| Endianness conversion functions.
| CO_LIST

| List management.
| CO_MATH

| Optimized math functions and other computations.
| CO_POOL

| common module.
| CO_RINGARRAY

| Ring buffer management.
| CO_STATUS

| Status definitions.
| CO_UTILS

| Common utilities.
| CO_BIT

| Bit manipulation useful macro.
| CO_BOOL

| Common boolean standard types (removes use of stdbool).
| CO_INT

| Common integer standard types (removes use of stdint).
## 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

Module grouping the general purpose SW tools.

This module contains the list management tools, math and endianess libraries, etc.

## 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.