diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-01 15:16:15 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-03 14:28:56 +0100 |
commit | 63186ac5f12e1782ffee25d982789e53ce3f692d (patch) | |
tree | 0f95390f960a87c6eef79796c997e0bb169a6782 | |
parent | ed91c8651a874527058b8e64e8246e520f084630 (diff) | |
download | ffmpeg-63186ac5f12e1782ffee25d982789e53ce3f692d.tar.gz |
avutil/mem: replace remaining void **/*** casts by memcpy()
This is similar to 60392480181f24ebf3ab48d8ac3614705de90152
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavutil/mem.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c index 155569e224..5fd2395dab 100644 --- a/libavutil/mem.c +++ b/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; |