ConOpSys V2970  P004.07
ANVILEX control operating system
Macros | Functions | Variables
memp.c File Reference
#include "lwip/opt.h"
#include "lwip/memp.h"
#include "lwip/sys.h"
#include "lwip/stats.h"
#include <string.h>
#include "lwip/pbuf.h"
#include "lwip/raw.h"
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/altcp.h"
#include "lwip/ip4_frag.h"
#include "lwip/netbuf.h"
#include "lwip/api.h"
#include "lwip/priv/tcpip_priv.h"
#include "lwip/priv/api_msg.h"
#include "lwip/priv/sockets_priv.h"
#include "lwip/etharp.h"
#include "lwip/igmp.h"
#include "lwip/timeouts.h"
#include "netif/ppp/ppp_opts.h"
#include "lwip/netdb.h"
#include "lwip/dns.h"
#include "lwip/priv/nd6_priv.h"
#include "lwip/ip6_frag.h"
#include "lwip/mld6.h"
#include "lwip/priv/memp_std.h"
Include dependency graph for memp.c:

Macros

#define LWIP_MEMPOOL(name, num, size, desc)   LWIP_MEMPOOL_DECLARE(name,num,size,desc)
 
#define LWIP_MEMPOOL(name, num, size, desc)   &memp_ ## name,
 

Functions

void memp_init_pool (const struct memp_desc *desc)
 
void memp_init (void)
 
static void * do_memp_malloc_pool (const struct memp_desc *desc)
 
void * memp_malloc_pool (const struct memp_desc *desc)
 
void * memp_malloc (memp_t type)
 
static void do_memp_free_pool (const struct memp_desc *desc, void *mem)
 
void memp_free_pool (const struct memp_desc *desc, void *mem)
 
void memp_free (memp_t type, void *mem)
 

Variables

const struct memp_desc *const memp_pools [MEMP_MAX]
 

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.

Macro Definition Documentation

◆ LWIP_MEMPOOL [1/2]

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

◆ LWIP_MEMPOOL [2/2]

#define LWIP_MEMPOOL (   name,
  num,
  size,
  desc 
)    &memp_ ## name,

Function Documentation

◆ do_memp_free_pool()

static void do_memp_free_pool ( const struct memp_desc desc,
void *  mem 
)
static

References LWIP_ASSERT, LWIP_UNUSED_ARG, MEM_ALIGNMENT, mem_free(), MEMP_SIZE, memp::next, SYS_ARCH_DECL_PROTECT, SYS_ARCH_PROTECT, SYS_ARCH_UNPROTECT, and memp_desc::tab.

Referenced by memp_free(), and memp_free_pool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_memp_malloc_pool()

static void* do_memp_malloc_pool ( const struct memp_desc desc)
static

◆ memp_free()

void memp_free ( memp_t  type,
void *  mem 
)

Put an element back into its pool.

Parameters
typethe pool where to put mem
memthe memp element to free

References do_memp_free_pool(), LWIP_ERROR, MEMP_MAX, memp_pools, NULL, and memp_desc::tab.

Referenced by pbuf_free(), tcpip_callbackmsg_delete(), tcpip_inpkt(), tcpip_thread_handle_msg(), and tcpip_try_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ memp_free_pool()

void memp_free_pool ( const struct memp_desc desc,
void *  mem 
)

Put a custom pool element back into its pool.

Parameters
descthe pool where to put mem
memthe memp element to free

References do_memp_free_pool(), LWIP_ASSERT, and NULL.

Here is the call graph for this function:

◆ memp_init()

void memp_init ( void  )

initialises lwIP built-in pools. Related functions: memp_malloc, memp_free

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

References LWIP_ARRAYSIZE, memp_init_pool(), and memp_pools.

Referenced by lwip_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ memp_init_pool()

void memp_init_pool ( const struct memp_desc desc)

initialise custom memory pool. Related functions: memp_malloc_pool, memp_free_pool

Parameters
descpool to initialise

References memp_desc::base, LWIP_MEM_ALIGN, LWIP_UNUSED_ARG, MEMP_OVERFLOW_CHECK, MEMP_SIZE, memp::next, NULL, memp_desc::num, memp_desc::size, and memp_desc::tab.

Referenced by memp_init().

Here is the caller graph for this function:

◆ memp_malloc()

void* memp_malloc ( memp_t  type)

Get an element from a specific pool.

Parameters
typethe pool to get an element from
Returns
a pointer to the allocated memory or a NULL pointer on error

References do_memp_malloc_pool(), LWIP_ERROR, MEMP_MAX, memp_pools, and NULL.

Referenced by pbuf_alloc(), pbuf_alloc_reference(), tcpip_callback(), tcpip_callbackmsg_new(), tcpip_inpkt(), and tcpip_try_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ memp_malloc_pool()

void* memp_malloc_pool ( const struct memp_desc desc)

Get an element from a custom pool.

Parameters
descthe pool to get an element from
Returns
a pointer to the allocated memory or a NULL pointer on error

References do_memp_malloc_pool(), LWIP_ASSERT, and NULL.

Here is the call graph for this function:

Variable Documentation

◆ memp_pools

const struct memp_desc* const memp_pools[MEMP_MAX]
Initial value:
= {
#define LWIP_MEMPOOL(name,num,size,desc)
}

Referenced by memp_free(), memp_init(), and memp_malloc().