[FFmpeg-cvslog] avutil/mem: Add av_fast_mallocz()

Michael Niedermayer git at videolan.org
Wed Nov 18 22:22:51 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Nov 18 14:19:47 2015 +0100| [fc91eeab0b3c59f431653dec4e7358630b2c1f7e] | committer: Michael Niedermayer

avutil/mem: Add av_fast_mallocz()

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fc91eeab0b3c59f431653dec4e7358630b2c1f7e
---

 doc/APIchanges      |    3 +++
 libavutil/mem.c     |    4 ++++
 libavutil/mem.h     |   15 +++++++++++++++
 libavutil/version.h |    2 +-
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 14b96ce..edeba02 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2015-11-18 - lavu 55.7.100 - mem.h
+  Add av_fast_mallocz()
+
 2015-10-29 - lavc 57.12.100 / 57.8.0 - avcodec.h
   xxxxxx - Deprecate av_free_packet(). Use av_packet_unref() as replacement,
            it resets the packet in a more consistent way.
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 323b183..8dfaad8 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -501,3 +501,7 @@ void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
     ff_fast_malloc(ptr, size, min_size, 0);
 }
 
+void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
+{
+    ff_fast_malloc(ptr, size, min_size, 1);
+}
diff --git a/libavutil/mem.h b/libavutil/mem.h
index a8eb14e..d25b322 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -385,6 +385,21 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
 
 /**
+ * Allocate a buffer, reusing the given one if large enough.
+ *
+ * All newly allocated space is initially cleared
+ * Contrary to av_fast_realloc the current buffer contents might not be
+ * preserved and on error the old buffer is freed, thus no special
+ * handling to avoid memleaks is necessary.
+ *
+ * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
+ * @param size size of the buffer *ptr points to
+ * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
+ *                 *size 0 if an error occurred.
+ */
+void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size);
+
+/**
  * @}
  */
 
diff --git a/libavutil/version.h b/libavutil/version.h
index bcad658..8198e6d 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -56,7 +56,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  55
-#define LIBAVUTIL_VERSION_MINOR   6
+#define LIBAVUTIL_VERSION_MINOR   7
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list