27 #define _XOPEN_SOURCE 600
48 #define malloc AV_JOIN(MALLOC_PREFIX, malloc)
49 #define memalign AV_JOIN(MALLOC_PREFIX, memalign)
50 #define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
51 #define realloc AV_JOIN(MALLOC_PREFIX, realloc)
52 #define free AV_JOIN(MALLOC_PREFIX, free)
54 void *malloc(
size_t size);
55 void *memalign(
size_t align,
size_t size);
56 int posix_memalign(
void **ptr,
size_t align,
size_t size);
57 void *realloc(
void *ptr,
size_t size);
64 #define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16))
84 #if HAVE_POSIX_MEMALIGN
88 #elif HAVE_ALIGNED_MALLOC
127 #if CONFIG_MEMORY_POISONING
139 #if HAVE_ALIGNED_MALLOC
170 memcpy(&
val, ptr,
sizeof(
val));
178 memcpy(ptr, &
val,
sizeof(
val));
210 memcpy(&
val, ptr,
sizeof(
val));
212 memcpy(ptr, &
val,
sizeof(
val));
221 #if HAVE_ALIGNED_MALLOC
241 memset(ptr, 0,
size);
257 size_t len = strlen(
s) + 1;
267 char *ret =
NULL, *end;
272 end = memchr(
s, 0,
len);
291 memcpy(ptr, p,
size);
299 memcpy(&
tab, tab_ptr,
sizeof(
tab));
303 memcpy(tab_ptr, &
tab,
sizeof(
tab));
313 memcpy(&
tab, tab_ptr,
sizeof(
tab));
317 memcpy(tab_ptr, &
tab,
sizeof(
tab));
330 tab_elem_data = (
uint8_t *)*tab_ptr + (*nb_ptr) * elem_size;
332 memcpy(tab_elem_data, elem_data, elem_size);
339 return tab_elem_data;
364 uint32_t
a = v << 8 | v >> 16;
365 uint32_t
b = v << 16 | v >> 8;
366 uint32_t
c = v << 24 | v;
369 uint32_t
a = v | v << 24;
370 uint32_t
b = v >> 8 | v << 16;
371 uint32_t
c = v >> 16 | v << 8;
405 uint64_t v2= v + ((uint64_t)v<<32);
435 memset(dst, *
src, cnt);
436 }
else if (back == 2) {
438 }
else if (back == 3) {
440 }
else if (back == 4) {
445 while (cnt > blocklen) {
446 memcpy(dst,
src, blocklen);
451 memcpy(dst,
src, cnt);
480 if (min_size <= *
size)
static double val(void *priv, double ch)
simple assert() macros that are a bit more flexible than ISO C assert().
Convenience header that includes libavutil's core.
common internal and external API header
#define CONFIG_MEMORY_POISONING
#define FF_DYNARRAY_ADD(av_size_max, av_elt_size, av_array, av_size, av_success, av_failure)
Add an element to a dynamic array.
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add the pointer to an element to a dynamic array.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
void * av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data)
Add an element of size elem_size to a dynamic array.
void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
Allocate and clear a buffer, reusing the given one if large enough.
void av_free(void *ptr)
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family.
void av_freep(void *arg)
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family,...
void * av_malloc_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_malloc().
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * av_strdup(const char *s)
Duplicate a string.
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
void * av_realloc_f(void *ptr, size_t nelem, size_t elsize)
Allocate, reallocate, or free a block of memory.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
static int av_size_mult(size_t a, size_t b, size_t *r)
Multiply two size_t values checking for overflow.
static void fill32(uint8_t *dst, int len)
static size_t max_alloc_size
static void fill16(uint8_t *dst, int len)
static void fill24(uint8_t *dst, int len)
Memory handling functions.
static int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
static const struct twinvq_data tab