From a91374a9161b3eac0d55b640f2a13831aefddd70 Mon Sep 17 00:00:00 2001 From: christiaans Date: Fri, 1 Dec 2006 15:38:56 +0000 Subject: [PATCH] Added MEM_LIBC_MALLOC option as workaround for failing mem_malloc(). --- CHANGELOG | 10 +++++++--- src/include/lwip/mem.h | 11 +++++++++-- src/include/lwip/opt.h | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 160382c0..8ad980ef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,12 +27,16 @@ HISTORY ++ New features: + 2006-12-01 Christiaan Simons + * mem.h, opt.h: Added MEM_LIBC_MALLOC option. + Note this is a workaround. Currently I have no other options left. + 2006-10-26 Christiaan Simons (accepted patch by Jonathan Larmour) - * src/core/ipv4/ip_frag.c: rename MAX_MTU to IP_FRAG_MAX_MTU and move define + * ipv4/ip_frag.c: rename MAX_MTU to IP_FRAG_MAX_MTU and move define to include/lwip/opt.h. - * include/ipv4/lwip/ip_frag.h: Remove unused IP_REASS_INTERVAL. + * ipv4/lwip/ip_frag.h: Remove unused IP_REASS_INTERVAL. Move IP_REASS_MAXAGE and IP_REASS_BUFSIZE to include/lwip/opt.h. - * include/lwip/opt.h: Add above new options. + * opt.h: Add above new options. 2006-08-18 Christiaan Simons * tcp_{in,out}.c: added SNMP counters. diff --git a/src/include/lwip/mem.h b/src/include/lwip/mem.h index 41d728d7..f14d1768 100644 --- a/src/include/lwip/mem.h +++ b/src/include/lwip/mem.h @@ -43,12 +43,19 @@ typedef u16_t mem_size_t; #define MEM_SIZE_F U16_F #endif /* MEM_SIZE > 64000 */ - +#if MEM_LIBC_MALLOC +/* aliases for C library malloc() */ +#define mem_init() +#define mem_free(x) free(x) +#define mem_malloc(x) malloc(x) +#define mem_realloc(x, size) realloc(x,size) +#else +/* lwIP alternative malloc */ void mem_init(void); - void *mem_malloc(mem_size_t size); void mem_free(void *mem); void *mem_realloc(void *mem, mem_size_t size); +#endif #ifndef MEM_ALIGN_SIZE #define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 153708ca..c8bdb49f 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -53,6 +53,10 @@ #define NO_SYS 0 #endif /* ---------- Memory options ---------- */ +#ifndef MEM_LIBC_MALLOC +#define MEM_LIBC_MALLOC 0 +#endif + /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2. */