ReactOS 0.4.16-dev-297-gc569aee
memp.h File Reference
#include "lwip/opt.h"
#include "lwip/priv/memp_std.h"
#include "lwip/priv/memp_priv.h"
#include "lwip/stats.h"
Include dependency graph for memp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LWIP_MEMPOOL(name, num, size, desc)
 
#define LWIP_MEMPOOL(name, num, size, desc)   MEMP_##name,
 
#define LWIP_MEMPOOL_PROTOTYPE(name)   extern const struct memp_desc memp_ ## name
 
#define LWIP_MEMPOOL_DECLARE(name, num, size, desc)
 
#define LWIP_MEMPOOL_INIT(name)   memp_init_pool(&memp_ ## name)
 
#define LWIP_MEMPOOL_ALLOC(name)   memp_malloc_pool(&memp_ ## name)
 
#define LWIP_MEMPOOL_FREE(name, x)   memp_free_pool(&memp_ ## name, (x))
 

Enumerations

enum  memp_t { MEMP_MAX }
 

Functions

void memp_init (void)
 
voidmemp_malloc (memp_t type)
 
void memp_free (memp_t type, void *mem)
 

Variables

const struct memp_desc *const memp_pools [MEMP_MAX]
 

Detailed Description

Memory pool API

Definition in file memp.h.

Macro Definition Documentation

◆ LWIP_MEMPOOL [1/2]

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

Definition at line 53 of file memp.h.

◆ LWIP_MEMPOOL [2/2]

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

Definition at line 53 of file memp.h.

Enumeration Type Documentation

◆ memp_t

Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end

Enumerator
MEMP_MAX 

Definition at line 52 of file memp.h.

52 {
53#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
54#include "lwip/priv/memp_std.h"
56} memp_t;
memp_t
Definition: memp.h:52
@ MEMP_MAX
Definition: memp.h:55

Function Documentation

◆ 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

Definition at line 420 of file memp.c.

421{
422#ifdef LWIP_HOOK_MEMP_AVAILABLE
423 struct memp *old_first;
424#endif
425
426 LWIP_ERROR("memp_free: type < MEMP_MAX", (type < MEMP_MAX), return;);
427
428 if (mem == NULL) {
429 return;
430 }
431
432#if MEMP_OVERFLOW_CHECK >= 2
433 memp_overflow_check_all();
434#endif /* MEMP_OVERFLOW_CHECK >= 2 */
435
436#ifdef LWIP_HOOK_MEMP_AVAILABLE
437 old_first = *memp_pools[type]->tab;
438#endif
439
441
442#ifdef LWIP_HOOK_MEMP_AVAILABLE
443 if (old_first == NULL) {
444 LWIP_HOOK_MEMP_AVAILABLE(type);
445 }
446#endif
447}
#define NULL
Definition: types.h:112
#define LWIP_ERROR(message, expression, handler)
Definition: debug.h:130
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void do_memp_free_pool(const struct memp_desc *desc, void *mem)
Definition: memp.c:359
const struct memp_desc *const memp_pools[MEMP_MAX]
Definition: memp.c:81
Definition: mem.c:349
Definition: memp_priv.h:69

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

◆ memp_init()

void memp_init ( void  )

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

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

Definition at line 224 of file memp.c.

225{
226 u16_t i;
227
228 /* for every pool: */
229 for (i = 0; i < LWIP_ARRAYSIZE(memp_pools); i++) {
231
232#if LWIP_STATS && MEMP_STATS
233 lwip_stats.memp[i] = memp_pools[i]->stats;
234#endif
235 }
236
237#if MEMP_OVERFLOW_CHECK >= 2
238 /* check everything a first time to see if it worked */
239 memp_overflow_check_all();
240#endif /* MEMP_OVERFLOW_CHECK >= 2 */
241}
#define LWIP_ARRAYSIZE(x)
Definition: def.h:69
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint16_t u16_t
Definition: arch.h:127
void memp_init_pool(const struct memp_desc *desc)
Definition: memp.c:175

Referenced by lwip_init().

◆ 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

Definition at line 337 of file memp.c.

341{
342 void *memp;
343 LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;);
344
345#if MEMP_OVERFLOW_CHECK >= 2
346 memp_overflow_check_all();
347#endif /* MEMP_OVERFLOW_CHECK >= 2 */
348
349#if !MEMP_OVERFLOW_CHECK
351#else
352 memp = do_memp_malloc_pool_fn(memp_pools[type], file, line);
353#endif
354
355 return memp;
356}
static void * do_memp_malloc_pool(const struct memp_desc *desc)
Definition: memp.c:245
Definition: fci.c:127
Definition: parser.c:49

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

Variable Documentation

◆ memp_pools

const struct memp_desc* const memp_pools[MEMP_MAX]
extern

Definition at line 81 of file memp.c.

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