summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2016-10-21 17:25:08 +0200
committerAxel Davy <[email protected]>2016-10-24 21:56:44 +0200
commit54010cf8b6da71a1b14c0dc586bb7e6be27052de (patch)
tree7f3da2e9c31e24b54921ca59a8d2d4ab7878bb77 /src/gallium
parent25beccb379731b0e6fc728982190779da47aa6fd (diff)
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 <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_memory.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_memory.h b/src/gallium/auxiliary/util/u_memory.h
index 597df6247a6..66c3ba4e410 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.