summaryrefslogtreecommitdiff
path: root/libavutil/mem.h
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki@gmail.com>2014-02-25 01:06:06 +0100
committerLukasz Marek <lukasz.m.luki@gmail.com>2014-03-29 09:48:48 +0100
commitcd50a44beb01582093b8115287cb51a7feb83f77 (patch)
tree4e3aebe2247f6f44964afb319ebca1f0b26baf1b /libavutil/mem.h
parent27256e69ab2df625a431dfe67c6a7aa364992a48 (diff)
lavu/mem: add av_dynarray_add_nofree function
av_dynarray_add_nofree function have similar functionality as existing av_dynarray_add, but it doesn't deallocate memory on fails. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat (limited to 'libavutil/mem.h')
-rw-r--r--libavutil/mem.h19
1 files changed, 17 insertions, 2 deletions
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);