aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-03-29 16:28:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-03-29 17:07:26 +0100
commitbcd5fd5346be263162792be595eff9fc08e5c853 (patch)
treeb832637e5bce2a8906f5e1802fb3906612c25a27 /libavutil
parent8a9d0a1561470a185a3d09676fcf9b44830a4bfe (diff)
parent3937b40e87c92993df6c62492c59f59cbeb97126 (diff)
downloadffmpeg-bcd5fd5346be263162792be595eff9fc08e5c853.tar.gz
Merge commit 'lukaszmluki/master^'
* commit 'lukaszmluki/master^': lavd/pulse_audio_enc: implement get_device_list callback lavd/pulse_audio_dec: implement get_device_list callback lavd/pulse_audio_common: add device detecting code lavu/mem: add av_dynarray_add_nofree function lavd/pulse_audio_enc: implement write_uncoded_frame callback tools/uncoded_frame: fix audio codec generation Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/mem.c13
-rw-r--r--libavutil/mem.h19
-rw-r--r--libavutil/version.h2
3 files changed, 31 insertions, 3 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index e0d0d9040b..8226168eed 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -278,6 +278,19 @@ void *av_memdup(const void *p, size_t size)
return ptr;
}
+int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
+{
+ void **tab = *(void ***)tab_ptr;
+
+ AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
+ tab[*nb_ptr] = elem;
+ *(void ***)tab_ptr = tab;
+ }, {
+ return AVERROR(ENOMEM);
+ });
+ return 0;
+}
+
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
{
void **tab = *(void ***)tab_ptr;
diff --git a/libavutil/mem.h b/libavutil/mem.h
index 703ce81936..801c53ff51 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -276,11 +276,26 @@ void av_freep(void *ptr);
* @param tab_ptr pointer to the array to grow
* @param nb_ptr pointer to the number of elements in the array
* @param elem element to add
- * @see av_dynarray2_add()
+ * @see av_dynarray_add_nofree(), av_dynarray2_add()
*/
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
/**
+ * Add an element to a dynamic array.
+ *
+ * Function has the same functionality as av_dynarray_add(),
+ * but it doesn't free memory on fails. It returns error code
+ * instead and leave current buffer untouched.
+ *
+ * @param tab_ptr pointer to the array to grow
+ * @param nb_ptr pointer to the number of elements in the array
+ * @param elem element to add
+ * @return >=0 on success, negative otherwise.
+ * @see av_dynarray_add(), av_dynarray2_add()
+ */
+int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem);
+
+/**
* Add an element of size elem_size to a dynamic array.
*
* The array is reallocated when its number of elements reaches powers of 2.
@@ -299,7 +314,7 @@ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
* the new added element is not filled.
* @return pointer to the data of the element to copy in the new allocated space.
* If NULL, the new allocated space is left uninitialized."
- * @see av_dynarray_add()
+ * @see av_dynarray_add(), av_dynarray_add_nofree()
*/
void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
const uint8_t *elem_data);
diff --git a/libavutil/version.h b/libavutil/version.h
index 45f5adc804..644f157242 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -56,7 +56,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 69
+#define LIBAVUTIL_VERSION_MINOR 70
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \