[FFmpeg-devel] [PATCH 1/4] lavu: add simple array implementation

Don Moir donmoir at comcast.net
Wed Mar 5 00:26:05 CET 2014


>From: "Michael Niedermayer" <michaelni at gmx.at>
>To: "FFmpeg development discussions and patches" <ffmpeg-devel at ffmpeg.org>
>Sent: Tuesday, March 04, 2014 6:03 PM
>Subject: Re: [FFmpeg-devel] [PATCH 1/4] lavu: add simple array implementation

>> >
>> > av_dynarray_add_nofree function have similar functionality
>> > as existing av_dynarray_add, but it doesn't deallocate memory
>> > on fails.
>>
>> I am sorry, but I still do not like it very much. It fixes one of the flaws
>> of av_dynarray_add(), but there are still others: you can not choose the
>> element size (this is only in the 2 variant; this version is even worse: it
>> assumes that sizeof(void *) == sizeof(intptr_t)),

>> you can not choose the
>> type for the size variable (at some places, it is convenient to be able to
>> use size_t).

>are you sure that you arent overdesigning this ?

I think the original implentations are underdesigned (why you probably have 2) and the way Lukasz is trying to design it is the 
right way to go. I have been using a similiar method for many years and use it for a variety of things and always accomodates. Works 
from C but with C++ I also use templates which makes it even better with less explicit initialization and free and it's typed.

I would rename Lukasz deleter to destructor though. Also within the struct, I provide a lock if you choose to use it. I use dynamic 
arrays a lot and sometimes with multi-thread usage. The way Lukasz is trying to design it probably has too much in it, but he is 
trying to accomodate the older implementations I believe. The other implementations should be marked as deprecated and re-routed to 
a new implementation in my opinion.






More information about the ffmpeg-devel mailing list