aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/mem.c
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.c
parent27256e69ab2df625a431dfe67c6a7aa364992a48 (diff)
downloadffmpeg-cd50a44beb01582093b8115287cb51a7feb83f77.tar.gz
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.c')
-rw-r--r--libavutil/mem.c13
1 files changed, 13 insertions, 0 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;