Deprecated fork of old network stack source from github. Please use official library instead: https://mbed.org/users/mbed_official/code/EthernetInterface/

Embed: (wiki syntax)

« Back to documentation index

memp.c File Reference

memp.c File Reference

Dynamic pool memory manager. More...

Go to the source code of this file.

Functions

static int memp_sanity (void)
 Check that memp-lists don't form a circle.
static void memp_overflow_check_element_overflow (struct memp *p, u16_t memp_type)
 Check if a memp element was victim of an overflow (e.g.
static void memp_overflow_check_element_underflow (struct memp *p, u16_t memp_type)
 Check if a memp element was victim of an underflow (e.g.
static void memp_overflow_check_all (void)
 Do an overflow check for all elements in every pool.
static void memp_overflow_init (void)
 Initialize the restricted areas of all memp elements in every pool.
void memp_init (void)
 Initialize this module.
void * memp_malloc (memp_t type) memp_malloc_fn(memp_t type
 Get an element from a specific pool.

Variables

static struct memp * memp_tab [MEMP_MAX]
 This array holds the first free element of each pool.
static const u16_t memp_sizes [MEMP_MAX]
 This array holds the element sizes of each pool.
static const u16_t memp_num [MEMP_MAX]
 This array holds the number of elements in each pool.
static const char * memp_desc [MEMP_MAX]
 This array holds a textual description of each pool.
static u8_t *const memp_bases []
 This array holds the base of each memory pool.
static u8_t memp_memory[MEM_ALIGNMENT-1#define
LWIP_MEMPOOL(name, num, size,
desc)+((num)*(MEMP_SIZE+MEMP_ALIGN_SIZE(size)))#include"lwip/memp_std.h"] 
ETHMEM_SECTION
 This is the actual memory used by the pools (all pools in one big block).

Detailed Description

Dynamic pool memory manager.

lwIP has dedicated pools for many structures (netconn, protocol control blocks, packet buffers, ...). All these pools are managed here.

Definition in file memp.c.


Function Documentation

void memp_init ( void   )

Initialize this module.

Carves out memp_memory into linked lists for each pool-type.

Definition at line 343 of file memp.c.

void* memp_malloc ( memp_t  type )

Get an element from a specific pool.

Parameters:
typethe pool to get an element from

the debug version has two more parameters:

Parameters:
filefile name calling this function
linenumber of line where this function is called
Returns:
a pointer to the allocated memory or a NULL pointer on error
static void memp_overflow_check_all ( void   ) [static]

Do an overflow check for all elements in every pool.

See also:
memp_overflow_check_element for a description of the check

Definition at line 286 of file memp.c.

static void memp_overflow_check_element_overflow ( struct memp *  p,
u16_t  memp_type 
) [static]

Check if a memp element was victim of an overflow (e.g.

the restricted area after it has been altered)

Parameters:
pthe memp element to check
memp_typethe pool p comes from

Definition at line 222 of file memp.c.

static void memp_overflow_check_element_underflow ( struct memp *  p,
u16_t  memp_type 
) [static]

Check if a memp element was victim of an underflow (e.g.

the restricted area before it has been altered)

Parameters:
pthe memp element to check
memp_typethe pool p comes from

Definition at line 255 of file memp.c.

static void memp_overflow_init ( void   ) [static]

Initialize the restricted areas of all memp elements in every pool.

Definition at line 313 of file memp.c.

static int memp_sanity ( void   ) [static]

Check that memp-lists don't form a circle.

Definition at line 188 of file memp.c.


Variable Documentation

u8_t memp_memory [MEM_ALIGNMENT - 1 #define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )#include "lwip/memp_std.h"] ETHMEM_SECTION [static]

This is the actual memory used by the pools (all pools in one big block).

Definition at line 179 of file memp.c.

u8_t* const memp_bases[] [static]
Initial value:
 { 
#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base,   
#include "lwip/memp_std.h"
}

This array holds the base of each memory pool.

Definition at line 162 of file memp.c.

const char* memp_desc[MEMP_MAX] [static]
Initial value:
 {
#define LWIP_MEMPOOL(name,num,size,desc)  (desc),
#include "lwip/memp_std.h"
}

This array holds a textual description of each pool.

Definition at line 144 of file memp.c.

const u16_t memp_num[MEMP_MAX] [static]
Initial value:
 {
#define LWIP_MEMPOOL(name,num,size,desc)  (num),
#include "lwip/memp_std.h"
}

This array holds the number of elements in each pool.

Definition at line 137 of file memp.c.

const u16_t memp_sizes[MEMP_MAX] [static]
Initial value:
 {
#define LWIP_MEMPOOL(name,num,size,desc)  LWIP_MEM_ALIGN_SIZE(size),
#include "lwip/memp_std.h"
}

This array holds the element sizes of each pool.

Definition at line 129 of file memp.c.

struct memp* memp_tab[MEMP_MAX] [static]

This array holds the first free element of each pool.

Elements form a linked list.

Definition at line 117 of file memp.c.