added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc is otherwise used)

This commit is contained in:
goldsimon
2009-02-11 20:43:41 +00:00
parent 6472e3b35e
commit c4509e700d
4 changed files with 44 additions and 4 deletions

View File

@@ -73,10 +73,22 @@ typedef enum {
We use this helper type and these defines so we can avoid using const memp_t values */
#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
extern const u16_t memp_sizes[MEMP_MAX];
#endif /* MEM_USE_POOLS */
#if MEMP_MEM_MALLOC || MEM_USE_POOLS
extern const u16_t memp_sizes[MEMP_MAX];
#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
#if MEMP_MEM_MALLOC
#include "mem.h"
#define memp_init()
#define memp_malloc(type) mem_malloc(memp_sizes[type])
#define memp_free(type, mem) mem_free(mem)
#else /* MEMP_MEM_MALLOC */
void memp_init(void);
#if MEMP_OVERFLOW_CHECK
@@ -87,6 +99,8 @@ void *memp_malloc(memp_t type);
#endif
void memp_free(memp_t type, void *mem);
#endif /* MEMP_MEM_MALLOC */
#ifdef __cplusplus
}
#endif

View File

@@ -98,6 +98,15 @@
#define MEM_LIBC_MALLOC 0
#endif
/**
* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
* speed and usage from interrupts!
*/
#ifndef MEMP_MEM_MALLOC
#define MEMP_MEM_MALLOC 0
#endif
/**
* MEM_ALIGNMENT: should be set to the alignment of the CPU
* 4 byte alignment -> #define MEM_ALIGNMENT 4
@@ -1120,7 +1129,7 @@
*/
#ifndef RECV_BUFSIZE_DEFAULT
#define RECV_BUFSIZE_DEFAULT INT_MAX
#endif /* RECV_BUFSIZE_DEFAULT */
#endif
/**
* SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!