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 _http_client_handle_entity(), _http_client_read_chuked_entity(), _tcc_build_faults(), app_task(), appDataInd(), bod_set_config(), build_data_frame(), chk_mounted(), f_lseek(), gfx_mono_spinctrl_spincollection_add_spinner(), handle_gts_data_req(), ieee11073_decode_metadata(), mac_parse_bcn_gts_info(), mac_ready_to_sleep(), nwkRxRejectDuplicate(), nwkTxAckReceived(), pbuf_header(), peer_search_receptor_rx_cb(), peer_search_receptor_task(), peer_search_receptor_tx_done_cb(), uhi_msc_scsi_test_unit_ready_sense(), usb_host_pipe_get_config(), usr_get_current_config_confirm(), usr_perf_start_confirm(), and usr_set_default_config_confirm().
LWIP_ERROR | ( | ) |
Referenced by pbuf_cat(), pbuf_copy(), pbuf_copy_partial(), pbuf_header(), and pbuf_take().
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 |
References LWIP_ASSERT, MEM_ALIGNMENT, memp, MEMP_SIZE, MEMP_STATS_DEC, memp::next, NULL, SYS_ARCH_DECL_PROTECT(), SYS_ARCH_PROTECT(), and SYS_ARCH_UNPROTECT().
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.
References err, i, j, LWIP_MEM_ALIGN, max, memp, MEMP_MAX, memp_memory, MEMP_OVERFLOW_CHECK, MEMP_SIZE, memp_sizes, MEMP_STATS_AVAIL, memp::next, and NULL.
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 |
Referenced by mem_free(), mem_trim(), memp_free(), pbuf_free(), and pbuf_ref().
SYS_ARCH_PROTECT | ( | old_level | ) |
Referenced by mem_free(), mem_trim(), memp_free(), pbuf_free(), and pbuf_ref().
SYS_ARCH_UNPROTECT | ( | old_level | ) |
Referenced by mem_free(), mem_trim(), memp_free(), pbuf_free(), and pbuf_ref().
else |
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().