mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
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.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
parent
25beccb379
commit
54010cf8b6
1 changed files with 8 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue