Module: Mesa Branch: master Commit: 54010cf8b6da71a1b14c0dc586bb7e6be27052de URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=54010cf8b6da71a1b14c0dc586bb7e6be27052de
Author: Axel Davy <axel.d...@ens.fr> Date: Fri Oct 21 17:25:08 2016 +0200 gallium/util: Add align_calloc Add implementation for align_calloc, which is align_malloc + memset. v2: add if (ptr) before memset. Fix indentation. Signed-off-by: Axel Davy <axel.d...@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haeh...@amd.com> --- src/gallium/auxiliary/util/u_memory.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h index 597df62..66c3ba4 100644 --- a/src/gallium/auxiliary/util/u_memory.h +++ b/src/gallium/auxiliary/util/u_memory.h @@ -63,6 +63,14 @@ extern "C" { #define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment) #define align_free(_ptr) os_free_aligned(_ptr) +static inline void * +align_calloc(size_t size, unsigned long alignment) +{ + void *ptr = align_malloc(size, alignment); + if (ptr) + memset(ptr, 0, size); + return ptr; +} /** * Duplicate a block of memory. _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit