From 1571881f7a33cba496d290403494179b17571fa0 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 8 May 2007 11:00:49 +0000 Subject: [PATCH] If MEM_LIBC_MALLOC==1, allow the defines (e.g. mem_malloc() -> malloc()) to be overriden in case the C-library malloc implementation is not protected against concurrent access. --- CHANGELOG | 5 +++++ src/include/lwip/mem.h | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 620f9277..091e8e44 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,11 @@ HISTORY ++ New features: + 2007-05-08 Simon Goldschmidt + * mem.h: If MEM_LIBC_MALLOC==1, allow the defines (e.g. mem_malloc() -> malloc()) + to be overriden in case the C-library malloc implementation is not protected + against concurrent access. + 2007-05-04 Simon Goldschmidt (Atte Kojo) * etharp.c: Introduced fast one-entry-cache to speed up ARP lookup when sending multiple packets to the same host. diff --git a/src/include/lwip/mem.h b/src/include/lwip/mem.h index f14d1768..751d3d5a 100644 --- a/src/include/lwip/mem.h +++ b/src/include/lwip/mem.h @@ -46,16 +46,25 @@ typedef u16_t mem_size_t; #if MEM_LIBC_MALLOC /* aliases for C library malloc() */ #define mem_init() +/* in case C library malloc() needs extra protection, + * allow these defines to be overridden. + */ +#ifndef mem_free #define mem_free(x) free(x) +#endif +#ifndef mem_malloc #define mem_malloc(x) malloc(x) +#endif +#ifndef mem_realloc #define mem_realloc(x, size) realloc(x,size) -#else +#endif +#else /* MEM_LIBC_MALLOC */ /* 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 +#endif /* MEM_LIBC_MALLOC */ #ifndef MEM_ALIGN_SIZE #define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))