From 95cbf95c501050013e45b94d37f5066246796362 Mon Sep 17 00:00:00 2001 From: marcbou Date: Thu, 16 Aug 2007 18:37:15 +0000 Subject: [PATCH] Added mem_calloc(). --- src/core/mem.c | 11 +++++++++++ src/include/lwip/mem.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/core/mem.c b/src/core/mem.c index 8c1c2b52..b0885267 100644 --- a/src/core/mem.c +++ b/src/core/mem.c @@ -500,4 +500,15 @@ mem_malloc(mem_size_t size) } #endif /* MEM_USE_POOLS */ + +void *mem_calloc(size_t count, size_t size) +{ + void *p; + + p = mem_malloc(count * size); + if(p) { + memset(p, 0, count * size); + } + return p; +} #endif /* !MEM_LIBC_MALLOC */ diff --git a/src/include/lwip/mem.h b/src/include/lwip/mem.h index 4091c964..f80e3b97 100644 --- a/src/include/lwip/mem.h +++ b/src/include/lwip/mem.h @@ -62,6 +62,9 @@ typedef u16_t mem_size_t; #ifndef mem_malloc #define mem_malloc(x) malloc(x) #endif +#ifndef mem_calloc +#define mem_calloc(x, y) calloc(x, y) +#endif #ifndef mem_realloc #define mem_realloc(x, size) realloc(x,size) #endif @@ -81,6 +84,7 @@ void *mem_realloc(void *mem, mem_size_t size); #endif /* MEM_USE_POOLS */ void *mem_malloc(mem_size_t size); void mem_free(void *mem); +void *mem_calloc(size_t count, size_t size); #endif /* MEM_LIBC_MALLOC */ #ifndef LWIP_MEM_ALIGN_SIZE