[vlc-devel] [RFC 3/3] vlc_arrays: append items in amortized O(1)

Steve Lhomme robux4 at ycbcr.xyz
Mon Jul 23 08:25:37 CEST 2018


On 22/07/2018 18:19, Denis Charmet wrote:
> Hi,
>
> On 2018-07-22 14:08, Rémi Denis-Courmont wrote:
>> Le jeudi 19 juillet 2018, 18:57:18 EEST Romain Vimont a écrit :
>>> typedef struct vlc_array_t
>>>  {
>>> +    size_t i_capacity;
>>
>> AFAICT, a new member is not really necessary.
>>
>> If you allocated by power of two, it'd be easy to detect when to 
>> expand/shrink
>> the allocation.
>
> Don't you fear that the exponential growth could cause other issues?

Adding 50% at each increase is also exponential just slower. My 
understanding is that Romain picked that value from common other 
implementations.

>
> Regards,
> -- 
> Denis Charmet - TypX
> Le mauvais esprit est un art de vivre
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list