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

Lukasz Marek lukasz.m.luki at gmail.com
Wed Mar 5 00:37:02 CET 2014

On 05.03.2014 00:03, Michael Niedermayer wrote:
> On Tue, Mar 04, 2014 at 11:24:50PM +0100, Nicolas George wrote:
>> Le quartidi 14 ventôse, an CCXXII, Lukasz Marek a écrit :
>>> >From 6cdb1cb4b846478c8d7bc3c44e9e5d474aca52e0 Mon Sep 17 00:00:00 2001
>>> From: Lukasz Marek <lukasz.m.luki at gmail.com>
>>> Date: Tue, 25 Feb 2014 01:06:06 +0100
>>> Subject: [PATCH 1/4] 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.
>> 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 still think that a macro is a better solution.
> macros can confuse the "user", especially these kind of smart macros
> that do tricks that C functions couldnt
> also the compiler
> tends to produce more cryptic error messages when there are mistakes
> in macro use than when there are mistakes in function use.

I assume you want whole function as a macro
This will also cause a lot of code duplication.

regarding sizeof(void *) == sizeof(intptr_t) it would be good to check 
it in standard, I had quick look and it is not defined, but the code 
exists for few years now, I believe there would be a problem already if 
it is not equal at some cases.

Best Regards,
Lukasz Marek

Royale with Cheese.

More information about the ffmpeg-devel mailing list