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