44 #define malloc AV_JOIN(MALLOC_PREFIX, malloc) 45 #define memalign AV_JOIN(MALLOC_PREFIX, memalign) 46 #define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign) 47 #define realloc AV_JOIN(MALLOC_PREFIX, realloc) 48 #define free AV_JOIN(MALLOC_PREFIX, free) 50 void *malloc(
size_t size);
51 void *memalign(
size_t align,
size_t size);
52 int posix_memalign(
void **ptr,
size_t align,
size_t size);
53 void *realloc(
void *ptr,
size_t size);
65 #if CONFIG_MEMALIGN_HACK 70 if (size > (INT_MAX - 32) || !size)
73 #if CONFIG_MEMALIGN_HACK 74 ptr = malloc(size + 32);
77 diff = ((-(long)ptr - 1) & 31) + 1;
78 ptr = (
char *)ptr + diff;
79 ((
char *)ptr)[-1] = diff;
80 #elif HAVE_POSIX_MEMALIGN 81 if (posix_memalign(&ptr, 32, size))
83 #elif HAVE_ALIGNED_MALLOC 84 ptr = _aligned_malloc(size, 32);
86 ptr = memalign(32, size);
119 #if CONFIG_MEMALIGN_HACK 124 if (size > (INT_MAX - 16))
127 #if CONFIG_MEMALIGN_HACK 131 diff = ((
char *)ptr)[-1];
132 return (
char *)realloc((
char *)ptr - diff, size + diff) + diff;
133 #elif HAVE_ALIGNED_MALLOC 134 return _aligned_realloc(ptr, size, 32);
136 return realloc(ptr, size);
149 memcpy(&val, ptr,
sizeof(val));
157 memcpy(ptr, &val,
sizeof(val));
163 if (!size || nmemb >= INT_MAX / size)
172 if (!size || nmemb >= INT_MAX / size)
179 memcpy(&val, ptr,
sizeof(val));
186 memcpy(ptr, &val,
sizeof(val));
192 #if CONFIG_MEMALIGN_HACK 194 free((
char *)ptr - ((
char *)ptr)[-1]);
195 #elif HAVE_ALIGNED_MALLOC 206 memcpy(&val, arg,
sizeof(val));
207 memcpy(arg, &(
void *){
NULL },
sizeof(val));
215 memset(ptr, 0, size);
223 int len = strlen(s) + 1;
233 char *ret =
NULL, *end;
238 end = memchr(s, 0, len);
273 uint32_t
a = v << 8 | v >> 16;
274 uint32_t
b = v << 16 | v >> 8;
275 uint32_t c = v << 24 | v;
278 uint32_t a = v | v << 24;
279 uint32_t b = v >> 8 | v << 16;
280 uint32_t c = v >> 16 | v << 8;
332 memset(dst, *src, cnt);
333 }
else if (back == 2) {
335 }
else if (back == 3) {
337 }
else if (back == 4) {
342 while (cnt > blocklen) {
343 memcpy(dst, src, blocklen);
348 memcpy(dst, src, cnt);
377 if (min_size < *size)
380 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
397 if (min_size < *size)
399 min_size =
FFMAX(17 * min_size / 16 + 32, min_size);
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
memory handling functions
static void fill16(uint8_t *dst, int len)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static void fill32(uint8_t *dst, int len)
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
char * av_strndup(const char *s, size_t len)
Duplicate a substring of the string s.
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
char * av_strdup(const char *s)
Duplicate the string s.
static void fill24(uint8_t *dst, int len)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
common internal and external API header
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...