Dynamic pool memory manager.
lwIP has dedicated pools for many structures (netconn, protocol control blocks, packet buffers, ...). All these pools are managed here.
#include "lwip/opt.h"
#include "lwip/memp.h"
#include "lwip/pbuf.h"
#include "lwip/udp.h"
#include "lwip/raw.h"
#include "lwip/tcp_impl.h"
#include "lwip/igmp.h"
#include "lwip/api.h"
#include "lwip/api_msg.h"
#include "lwip/tcpip.h"
#include "lwip/sys.h"
#include "lwip/timers.h"
#include "lwip/stats.h"
#include "netif/etharp.h"
#include "lwip/ip_frag.h"
#include "lwip/snmp_structs.h"
#include "lwip/snmp_msg.h"
#include "lwip/dns.h"
#include "netif/ppp_oe.h"
#include <string.h>
#include "lwip/memp_std.h"
Data Structures | |
struct | memp |
Macros | |
#define | LWIP_MEMPOOL(name, num, size, desc) LWIP_MEM_ALIGN_SIZE(size), |
#define | LWIP_MEMPOOL(name, num, size, desc) (num), |
#define | LWIP_MEMPOOL(name, num, size, desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) |
#define | MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) |
#define | MEMP_SIZE 0 |
Functions | |
if (memp!=NULL) | |
LWIP_ERROR ("memp_malloc: type < MEMP_MAX",(type< MEMP_MAX), return NULL;) | |
void | memp_free (memp_t type, void *mem) |
Put an element back into its pool. More... | |
void | memp_init (void) |
Initialize this module. More... | |
MEMP_STATS_INC (err, type) | |
void * | SYS_ARCH_DECL_PROTECT (old_level) |
Get an element from a specific pool. More... | |
SYS_ARCH_PROTECT (old_level) | |
SYS_ARCH_UNPROTECT (old_level) | |
Variables | |
else | |
memp = memp_tab[type] | |
static u8_t | memp_memory [MEM_ALIGNMENT-1#define LWIP_MEMPOOL(name, num, size, desc)] |
This array holds a textual description of each pool. More... | |
static const u16_t | memp_num [MEMP_MAX] |
This array holds the number of elements in each pool. More... | |
static const u16_t | memp_sizes [MEMP_MAX] |
This array holds the element sizes of each pool. More... | |
static struct memp * | memp_tab [MEMP_MAX] |
This array holds the first free element of each pool. More... | |
#define LWIP_MEMPOOL | ( | name, | |
num, | |||
size, | |||
desc | |||
) | LWIP_MEM_ALIGN_SIZE(size), |
#define LWIP_MEMPOOL | ( | name, | |
num, | |||
size, | |||
desc | |||
) | (num), |
#define LWIP_MEMPOOL | ( | name, | |
num, | |||
size, | |||
desc | |||
) | + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) |
#define MEMP_ALIGN_SIZE | ( | x | ) | (LWIP_MEM_ALIGN_SIZE(x)) |
#define MEMP_SIZE 0 |
Referenced by if(), memp_free(), and memp_init().
if | ( | memp! | = NULL | ) |
References LWIP_ASSERT, MEM_ALIGNMENT, MEMP_SIZE, MEMP_STATS_INC_USED, memp::next, and NULL.
Referenced by app_task(), appDataInd(), build_data_frame(), chk_mounted(), f_lseek(), flashcalw_memset64(), handle_gts_data_req(), ieee11073_decode_metadata(), ip_input(), mac_parse_bcn_gts_info(), mac_ready_to_sleep(), nwkRxRejectDuplicate(), nwkTxAckReceived(), pbuf_header(), pbuf_header_impl(), peer_search_receptor_rx_cb(), peer_search_receptor_task(), peer_search_receptor_tx_done_cb(), uhi_msc_scsi_test_unit_ready_sense(), usr_get_current_config_confirm(), usr_perf_start_confirm(), and usr_set_default_config_confirm().
LWIP_ERROR | ( | ) |
void memp_free | ( | memp_t | type, |
void * | mem | ||
) |
Put an element back into its pool.
type | the pool where to put mem |
mem | the memp element to free |
Referenced by pbuf_free(), tcpip_callback_with_block(), tcpip_callbackmsg_delete(), tcpip_input(), and tcpip_thread().
void memp_init | ( | void | ) |
Initialize this module.
Carves out memp_memory into linked lists for each pool-type.
Referenced by lwip_init().
MEMP_STATS_INC | ( | err | , |
type | |||
) |
void* SYS_ARCH_DECL_PROTECT | ( | old_level | ) |
Get an element from a specific pool.
type | the pool to get an element from |
the debug version has two more parameters:
file | file name calling this function |
line | number of line where this function is called |
SYS_ARCH_PROTECT | ( | old_level | ) |
SYS_ARCH_UNPROTECT | ( | old_level | ) |
else |
Referenced by start_rpc().
Referenced by memp_free(), and memp_init().
|
static |
This array holds a textual description of each pool.
This is the actual memory used by the pools (all pools in one big block).
Referenced by memp_init().
This array holds the number of elements in each pool.
This array holds the element sizes of each pool.
Referenced by memp_init().