diff --git a/src/stdlib/lv_mem.c b/src/stdlib/lv_mem.c index bfc887fff..ece066783 100644 --- a/src/stdlib/lv_mem.c +++ b/src/stdlib/lv_mem.c @@ -116,6 +116,17 @@ void * lv_malloc_zeroed(size_t size) return alloc; } +void * lv_calloc(size_t num, size_t size) +{ + LV_TRACE_MEM("allocating number of %zu each %zu bytes", num, size); + return lv_malloc_zeroed(num * size); +} + +void * lv_zalloc(size_t size) +{ + return lv_malloc_zeroed(size); +} + void lv_free(void * data) { LV_TRACE_MEM("freeing %p", data); diff --git a/src/stdlib/lv_mem.h b/src/stdlib/lv_mem.h index 210c18988..6385dda96 100644 --- a/src/stdlib/lv_mem.h +++ b/src/stdlib/lv_mem.h @@ -68,6 +68,21 @@ void lv_mem_remove_pool(lv_mem_pool_t pool); */ void * lv_malloc(size_t size); +/** + * Allocate a block of zeroed memory dynamically + * @param num requested number of element to be allocated. + * @param size requested size of each element in bytes. + * @return pointer to allocated zeroed memory, or NULL on failure + */ +void * lv_calloc(size_t num, size_t size); + +/** + * Allocate zeroed memory dynamically + * @param size requested size in bytes + * @return pointer to allocated zeroed memory, or NULL on failure + */ +void * lv_zalloc(size_t size); + /** * Allocate zeroed memory dynamically * @param size requested size in bytes