[Mesa-dev] [PATCH 1/4] gallium/util: Add align_calloc
Axel Davy
axel.davy at ens.fr
Sat Oct 22 14:53:58 UTC 2016
On 22/10/2016 16:42, Brian Paul wrote:
> On Sat, Oct 22, 2016 at 4:28 AM, Axel Davy <axel.davy at ens.fr
> <mailto:axel.davy at ens.fr>> wrote:
>
> Add implementation for align_calloc,
> which is align_malloc + memset.
>
> Signed-off-by: Axel Davy <axel.davy at ens.fr <mailto:axel.davy at ens.fr>>
> ---
> src/gallium/auxiliary/util/u_memory.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_memory.h
> b/src/gallium/auxiliary/util/u_memory.h
> index 597df62..c72d19f 100644
> --- a/src/gallium/auxiliary/util/u_memory.h
> +++ b/src/gallium/auxiliary/util/u_memory.h
> @@ -63,6 +63,13 @@ 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.
> --
>
>
> -Brian
>
>
Indeed, thanks !
Axel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161022/08cc4e2e/attachment.html>
More information about the mesa-dev
mailing list