On Sun, 2012-07-08 at 18:06 +0200, Diego Biurrun wrote:
> On Sun, Jul 08, 2012 at 05:18:23PM +0200, Tomas Härdin wrote:
> > --- a/libavutil/mem.h
> > +++ b/libavutil/mem.h
> > @@ -113,6 +113,18 @@ void av_free(void *ptr);
> >  
> >  /**
> > + * Allocate a block of nmemb * size bytes with alignment suitable for all
> > + * memory accesses (including vectors if available on the CPU) and
> > + * zero all the bytes of the block.
> > + * The allocation will fail if nmemb * size is greater than or equal
> > + * to INT_MAX.
> > + * @param nmemb
> > + * @param size
> > + * @return Pointer to the allocated block, NULL if it cannot be allocated.
> > + */
> > +void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
> 
> Please fix the @param descriptions and squash patch 2/2 into this one.
> Otherwise LGTM.

Done. I kept the original author since the changes to the patch are
trivial.

/Tomas
>From f5d4ce51915b02e440c6598ca601185b725771fc Mon Sep 17 00:00:00 2001
From: Laurent Aimar <fen...@videolan.org>
Date: Sat, 24 Sep 2011 18:39:13 +0200
Subject: [PATCH] Add av_calloc() helper and bump lavu minor version

Signed-off-by: Michael Niedermayer <michae...@gmx.at>
---
 doc/APIchanges      |    3 +++
 libavutil/mem.c     |    7 +++++++
 libavutil/mem.h     |   12 ++++++++++++
 libavutil/version.h |    2 +-
 4 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 990e36e..80b9518 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-07-08 - xxxxxxx - lavu 51.37.0
+  Add av_calloc()
+
 2012-06-22 - xxxxxxx - lavu 51.34.0
   Add av_usleep()
 
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);
+}
+
 char *av_strdup(const char *s)
 {
     char *ptr= NULL;
diff --git a/libavutil/mem.h b/libavutil/mem.h
index cd8490b..4eb8f1b 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -113,6 +113,18 @@ void av_free(void *ptr);
 void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
 
 /**
+ * Allocate a block of nmemb * size bytes with alignment suitable for all
+ * memory accesses (including vectors if available on the CPU) and
+ * zero all the bytes of the block.
+ * The allocation will fail if nmemb * size is greater than or equal
+ * to INT_MAX.
+ * @param nmemb Number of elements to allocate
+ * @param size The size of each element in bytes
+ * @return Pointer to the allocated block, NULL if it cannot be allocated.
+ */
+void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
+
+/**
  * Duplicate the string s.
  * @param s string to be duplicated
  * @return Pointer to a newly allocated string containing a
diff --git a/libavutil/version.h b/libavutil/version.h
index c42c6b0..f55a99f 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -37,7 +37,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 36
+#define LIBAVUTIL_VERSION_MINOR 37
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
1.7.5.4

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to