[FFmpeg-cvslog] Move ff_dynarray_add to lavu and make it public.

Anton Khirnov git at videolan.org
Sun May 1 00:27:05 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Apr 29 17:33:38 2011 +0200| [35ceaa737643008e89a9ba54aaa9ebc0b57683b4] | committer: Anton Khirnov

Move ff_dynarray_add to lavu and make it public.

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

 doc/APIchanges         |    4 ++++
 libavformat/cutils.c   |   21 ---------------------
 libavformat/internal.h |    6 ++----
 libavutil/avutil.h     |    2 +-
 libavutil/mem.c        |   20 ++++++++++++++++++++
 libavutil/mem.h        |    9 +++++++++
 6 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 87ea7eb..0cd4904 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-04-xx - xxxxxxx - lavu 51.2.0 - mem.h
+  Add av_dynarray_add function for adding
+  an element to a dynamic array.
+
 2011-04-XX - bebe72f - lavu 51.1.0 - avutil.h
   Add AVPictureType enum and av_get_picture_type_char(), deprecate
   FF_*_TYPE defines and av_get_pict_type_char() defined in
diff --git a/libavformat/cutils.c b/libavformat/cutils.c
index 092aa8a..ef1c026 100644
--- a/libavformat/cutils.c
+++ b/libavformat/cutils.c
@@ -21,27 +21,6 @@
 #include "avformat.h"
 #include "internal.h"
 
-/* add one element to a dynamic array */
-void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem)
-{
-    /* see similar ffmpeg.c:grow_array() */
-    int nb, nb_alloc;
-    intptr_t *tab;
-
-    nb = *nb_ptr;
-    tab = *tab_ptr;
-    if ((nb & (nb - 1)) == 0) {
-        if (nb == 0)
-            nb_alloc = 1;
-        else
-            nb_alloc = nb * 2;
-        tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
-        *tab_ptr = tab;
-    }
-    tab[nb++] = elem;
-    *nb_ptr = nb;
-}
-
 #define ISLEAP(y) (((y) % 4 == 0) && (((y) % 100) != 0 || ((y) % 400) == 0))
 #define LEAPS_COUNT(y) ((y)/4 - (y)/100 + (y)/400)
 
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 6f1305c..0b8a35f 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -31,20 +31,18 @@ typedef struct AVCodecTag {
     unsigned int tag;
 } AVCodecTag;
 
-void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
-
 #ifdef __GNUC__
 #define dynarray_add(tab, nb_ptr, elem)\
 do {\
     __typeof__(tab) _tab = (tab);\
     __typeof__(elem) _elem = (elem);\
     (void)sizeof(**_tab == _elem); /* check that types are compatible */\
-    ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
+    av_dynarray_add(_tab, nb_ptr, _elem);\
 } while(0)
 #else
 #define dynarray_add(tab, nb_ptr, elem)\
 do {\
-    ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
+    av_dynarray_add((tab), nb_ptr, (elem));\
 } while(0)
 #endif
 
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 43f0815..8b8ca40 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -40,7 +40,7 @@
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
 #define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR  1
+#define LIBAVUTIL_VERSION_MINOR  2
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 27bb30b..85e1924 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -171,3 +171,23 @@ char *av_strdup(const char *s)
     return ptr;
 }
 
+/* add one element to a dynamic array */
+void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
+{
+    /* see similar ffmpeg.c:grow_array() */
+    int nb, nb_alloc;
+    intptr_t *tab;
+
+    nb = *nb_ptr;
+    tab = *(intptr_t**)tab_ptr;
+    if ((nb & (nb - 1)) == 0) {
+        if (nb == 0)
+            nb_alloc = 1;
+        else
+            nb_alloc = nb * 2;
+        tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
+        *(intptr_t**)tab_ptr = tab;
+    }
+    tab[nb++] = (intptr_t)elem;
+    *nb_ptr = nb;
+}
diff --git a/libavutil/mem.h b/libavutil/mem.h
index 5dea492..2be9491 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -123,4 +123,13 @@ char *av_strdup(const char *s) av_malloc_attrib;
  */
 void av_freep(void *ptr);
 
+/**
+ * Add an element to a dynamic array.
+ *
+ * @param tab_ptr Pointer to the array.
+ * @param nb_ptr  Pointer to the number of elements in the array.
+ * @param elem    Element to be added.
+ */
+void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
+
 #endif /* AVUTIL_MEM_H */



More information about the ffmpeg-cvslog mailing list