[vlc-devel] [RFC 0/3] Improving vlc_array_t
Denis Charmet
typx at dinauz.org
Sun Jul 22 18:16:18 CEST 2018
Hi,
On 2018-07-19 17:57, Romain Vimont wrote:
> There are 3 arrays API in vlc_arrays.h:
> 1. TAB_* macros
> 2. ARRAY_* macros
> 3. vlc_array_t + functions
>
> When we want a dynamic array of pointers, the vlc_array_t seems more
> appropriate. Moreover, the macro versions abort() on allocation
> failure.
In my opinion, an array of void* pointers feels generic to the point of
waste.
I completely get that handling insertion, deletion, lookup for every
structure is a PITA but I think that arrays of void* are more nefarious
than useful.
Vectors are awesome but as far as I know they handle more cases than
the vlc_array_t: they allocate the size of the object, call its
destructor on deletion and ensure type safety. To be fair, I would
personally prefer if the array allocated the whole size of each element,
like calloc does but I agree that it probably won't be enough since we
have no way in C to enforce the C++ rule of 3
(constructor/destructor/copy) to make it safer.
In that regard, I prefer the TAB_ macros for their flexibility and type
preserving even with their drawbacks and would love to see them improved
rather than relying on arrays of void* pointers.
In any case I agree that the playlist should be flat and ordered. I
lack the algorithmic theoretical knowledge to propose a better structure
than an array or a linked chain. But maybe if you elaborate on what the
playlist elements will actually hold we could come up with a proposition
that will satisfy everybody.
Regards,
--
Denis Charmet - TypX
Le mauvais esprit est un art de vivre
More information about the vlc-devel
mailing list