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

This is similar to 6039248018

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/115/head^2
Michael Niedermayer 10 years ago
parent ed91c8651a
commit 63186ac5f1
  1. 20
      libavutil/mem.c

@ -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;

Loading…
Cancel
Save