Tomas Härdin <tomas.har...@codemill.se> writes:

> Hi
>
> The attached patch adds av_calloc() to libavutil.
> See the mxfdec thread ("[PATCH] mxfdec: replace x>>av_log2(sizeof(..))
> by x/sizeof(..)"). This allows for simpler, smaller code and smaller
> binaries.
>
> /Tomas
>
> From f614808c28a58c14906c81962871d2c2dfc73afe Mon Sep 17 00:00:00 2001
> From: Laurent Aimar <fen...@videolan.org>
> Date: Sat, 24 Sep 2011 18:39:13 +0200
> Subject: [PATCH 1/2] Add av_calloc() helper.
>
> Signed-off-by: Michael Niedermayer <michae...@gmx.at>
> ---
>  libavutil/mem.c |    7 +++++++
>  libavutil/mem.h |   12 ++++++++++++
>  2 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/libavutil/mem.c b/libavutil/mem.c
> index 0fe9f54..45b024d 100644
> --- a/libavutil/mem.c
> +++ b/libavutil/mem.c
> @@ -167,6 +167,13 @@ void *av_mallocz(size_t size)
>      return ptr;
>  }
>
> +void *av_calloc(size_t nmemb, size_t size)
> +{
> +    if (size <= 0 || nmemb >= INT_MAX / size)
> +        return NULL;
> +    return av_mallocz(nmemb * size);
> +}

The places where this would be used don't in general need zeroed memory.

-- 
Måns Rullgård
m...@mansr.com
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to