[FFmpeg-devel] [PATCH 2/5] lavf/mkv: use av_dynarray_alloc_elem().

Clément Bœsch ubitux at gmail.com
Sun Apr 14 03:07:55 CEST 2013


---
 libavformat/matroskadec.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index ad0401a..041e526 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -943,18 +943,14 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
     uint32_t id = syntax->id;
     uint64_t length;
     int res;
-    void *newelem;
 
     data = (char *)data + syntax->data_offset;
     if (syntax->list_elem_size) {
         EbmlList *list = data;
-        newelem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size);
-        if (!newelem)
+        data = av_dynarray_alloc_elem(&list->elem, &list->nb_elem, syntax->list_elem_size);
+        if (!data)
             return AVERROR(ENOMEM);
-        list->elem = newelem;
-        data = (char*)list->elem + list->nb_elem*syntax->list_elem_size;
         memset(data, 0, syntax->list_elem_size);
-        list->nb_elem++;
     }
 
     if (syntax->type != EBML_PASS && syntax->type != EBML_STOP) {
-- 
1.8.2.1



More information about the ffmpeg-devel mailing list