[FFmpeg-devel] [PATCH 1/4] lavu: add simple array implementation
Lukasz Marek
lukasz.m.luki2 at gmail.com
Thu Mar 20 22:44:41 CET 2014
>> mem.c | 13 +++++++++++++
>> mem.h | 19 +++++++++++++++++--
>> 2 files changed, 30 insertions(+), 2 deletions(-)
>> 7fad1be9083fcaef4435fa0273f79bceca98821b 0001-lavu-mem-add-av_dynarray_add_nofree-function.patch
>> From 4cadb3328ba018b37c5dfe05a637b50a262151c6 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] 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.
>>
>> TODO: minor bump and update doc/APIChanges
>>
>> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
>> ---
>> libavutil/mem.c | 13 +++++++++++++
>> libavutil/mem.h | 19 +++++++++++++++++--
>> 2 files changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavutil/mem.c b/libavutil/mem.c
>> index 7206ddc..b9b5742 100644
>> --- a/libavutil/mem.c
>> +++ b/libavutil/mem.c
>> @@ -278,6 +278,19 @@ void *av_memdup(const void *p, size_t size)
>> return ptr;
>> }
>>
>> +int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
>> +{
>
>> + intptr_t *tab = *(intptr_t**)tab_ptr;
>
> undefined behavior (strict aliasing violation)
Can you tell how it is wrong?
>
>> +
>> + AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
>> + tab[*nb_ptr] = (intptr_t)elem;
>> + *(intptr_t **)tab_ptr = tab;
>> + }, {
>> + return AVERROR(ENOMEM);
>> + });
>
> cant comment, i have no clue what this does
>
> [...]
More information about the ffmpeg-devel
mailing list