Loading...
Searching...
No Matches
Memory pools
Infrastructure

## Macros

#define | LWIP_MEMPOOL_PROTOTYPE(name)
#define | LWIP_MEMPOOL_DECLARE(name, num, size, desc)
#define | LWIP_MEMPOOL_INIT(name)
#define | LWIP_MEMPOOL_ALLOC(name)
#define | LWIP_MEMPOOL_FREE(name, x)

## Detailed Description

Custom memory pools

## Macro Definition Documentation

## LWIP_MEMPOOL_ALLOC

#define LWIP_MEMPOOL_ALLOC | ( |  | name | ) |

Value:
memp_malloc_pool(&memp_ ## name)
memp_malloc_pool
void * memp_malloc_pool(const struct memp_desc *desc)
Definition memp.c:311

Allocate from a private memory pool

## LWIP_MEMPOOL_DECLARE

#define LWIP_MEMPOOL_DECLARE | ( |  | name,
|  |  | num,
|  |  | size,
|  |  | desc )

Value:
LWIP_DECLARE_MEMORY_ALIGNED(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \
\
LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \
\
static struct memp *memp_tab_ ## name; \
\
const struct memp_desc memp_ ## name = { \
DECLARE_LWIP_MEMPOOL_DESC(desc) \
LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \
LWIP_MEM_ALIGN_SIZE(size), \
(num), \
memp_memory_ ## name ## _base, \
&memp_tab_ ## name \
};
LWIP_DECLARE_MEMORY_ALIGNED
#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size)
Definition arch.h:271
memp_desc
Definition memp_priv.h:108

Declare a private memory pool Private mempools example: .h: only when pool is used in multiple .c files: LWIP_MEMPOOL_PROTOTYPE(my_private_pool); .c:

- in global variables section: LWIP_MEMPOOL_DECLARE(my_private_pool, 10, sizeof(foo), "Some description")
- call ONCE before using pool (e.g. in some init() function): LWIP_MEMPOOL_INIT(my_private_pool);
- allocate: void* my_new_mem = LWIP_MEMPOOL_ALLOC(my_private_pool);
- free: LWIP_MEMPOOL_FREE(my_private_pool, my_new_mem);

To relocate a pool, declare it as extern in cc.h. Example for GCC: extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_my_private_pool_base[];

## LWIP_MEMPOOL_FREE

#define LWIP_MEMPOOL_FREE | ( |  | name,
|  |  | x )

Value:
memp_free_pool(&memp_ ## name, (x))
memp_free_pool
void memp_free_pool(const struct memp_desc *desc, void *mem)
Definition memp.c:403

Free element from a private memory pool

## LWIP_MEMPOOL_INIT

#define LWIP_MEMPOOL_INIT | ( |  | name | ) |

Value:
memp_init_pool(&memp_ ## name)
memp_init_pool
void memp_init_pool(const struct memp_desc *desc)
Definition memp.c:175

Initialize a private memory pool

## LWIP_MEMPOOL_PROTOTYPE

#define LWIP_MEMPOOL_PROTOTYPE | ( |  | name | ) |

Value:
extern const struct memp_desc memp_ ## name

Declare prototype for private memory pool if it is used in multiple files