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

Nicolas George george at nsup.org
Wed Mar 5 13:46:41 CET 2014


Le quintidi 15 ventôse, an CCXXII, Don Moir a écrit :
> You got anything else idiodic to say or is that the best you can do?

With that acerbic remark, you just show you missed the point completely.

The line of reasoning that you are following is exactly the same that drives
the design of java's API: you have an interface, and then an abstract class
that implements the interface, and then an actual class that extends the
abstract class, and yet another class to extend the previous one, and at
each level there are two or three more variants that implements another
interface too or use a slightly different data structure. I am not making
this up: can anyone remember the relations between List, Vector, Collection,
ArrayList, Set without perusing the doc? And do not get me started on the
thread-safe / thread-unsafe variants.

The marketing pitch for that is that you should use the interface you need,
and any implementation will work with it. The reality, for complex projects,
is that different parts have different needs and chose different interfaces
and implementations, and are therefore incompatible.

lavu is not a java library, it is C, and not even I-write-C-like-I-would-
write-java-becase-I-am-too-dumb-to-write-real-C. In C, a dynamic array is a
pointer to mallocated memory, plus an integer to store the size. That is it.

For example, there is no need for a "deleter", because you usually know at
build-time what your array contains and how to free it. Of course, you can
add that king of things in a complex high-level data structure, because it
does not cost much.

But we are talking about an array, here, this is as low level as you can
get.

The current implementations of av_dynarray(2)_add() have flaws, but they are
exactly in the lavu optic: simple, low-level and efficient. The last version
Lukasz sent too, including some of the flaws.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140305/3f0c65ff/attachment.asc>


More information about the ffmpeg-devel mailing list