Commit 63186ac5 authored by Michael Niedermayer's avatar Michael Niedermayer

avutil/mem: replace remaining void **/*** casts by memcpy()

This is similar to 60392480Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ed91c865
......@@ -307,11 +307,12 @@ void *av_memdup(const void *p, size_t size)
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
{
void **tab = *(void ***)tab_ptr;
void **tab;
memcpy(&tab, tab_ptr, sizeof(tab));
AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
tab[*nb_ptr] = elem;
*(void ***)tab_ptr = tab;
memcpy(tab_ptr, &tab, sizeof(tab));
}, {
return AVERROR(ENOMEM);
});
......@@ -320,11 +321,12 @@ int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
{
void **tab = *(void ***)tab_ptr;
void **tab;
memcpy(&tab, tab_ptr, sizeof(tab));
AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
tab[*nb_ptr] = elem;
*(void ***)tab_ptr = tab;
memcpy(tab_ptr, &tab, sizeof(tab));
}, {
*nb_ptr = 0;
av_freep(tab_ptr);
......@@ -494,13 +496,15 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
{
void **p = ptr;
void *val;
if (min_size < *size)
return 0;
min_size = FFMAX(17 * min_size / 16 + 32, min_size);
av_free(*p);
*p = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
if (!*p)
av_freep(ptr);
val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
memcpy(ptr, &val, sizeof(val));
if (!val)
min_size = 0;
*size = min_size;
return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment