27 #define _XOPEN_SOURCE 600
46 #define malloc AV_JOIN(MALLOC_PREFIX, malloc)
47 #define memalign AV_JOIN(MALLOC_PREFIX, memalign)
48 #define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
49 #define realloc AV_JOIN(MALLOC_PREFIX, realloc)
50 #define free AV_JOIN(MALLOC_PREFIX, free)
52 void *malloc(
size_t size);
53 void *memalign(
size_t align,
size_t size);
54 int posix_memalign(
void **ptr,
size_t align,
size_t size);
55 void *realloc(
void *ptr,
size_t size);
60 #define ALIGN (HAVE_AVX ? 32 : 16)
76 #if CONFIG_MEMALIGN_HACK
84 #if CONFIG_MEMALIGN_HACK
85 ptr = malloc(size +
ALIGN);
88 diff = ((~(long)ptr)&(
ALIGN - 1)) + 1;
89 ptr = (
char *)ptr + diff;
90 ((
char *)ptr)[-1] =
diff;
91 #elif HAVE_POSIX_MEMALIGN
93 if (posix_memalign(&ptr,
ALIGN, size))
95 #elif HAVE_ALIGNED_MALLOC
96 ptr = _aligned_malloc(size,
ALIGN);
99 ptr = memalign(
ALIGN, size);
101 ptr = memalign(size,
ALIGN);
134 #if CONFIG_MEMORY_POISONING
136 memset(ptr, 0x2a, size);
143 #if CONFIG_MEMALIGN_HACK
151 #if CONFIG_MEMALIGN_HACK
155 diff = ((
char *)ptr)[-1];
157 ptr = realloc((
char *)ptr - diff, size + diff);
159 ptr = (
char *)ptr + diff;
161 #elif HAVE_ALIGNED_MALLOC
162 return _aligned_realloc(ptr, size + !size,
ALIGN);
164 return realloc(ptr, size + !size);
185 #if CONFIG_MEMALIGN_HACK
187 int v= ((
char *)ptr)[-1];
189 free((
char *)ptr - v);
191 #elif HAVE_ALIGNED_MALLOC
200 void **ptr = (
void **)arg;
209 memset(ptr, 0, size);
215 if (size <= 0 || nmemb >= INT_MAX / size)
224 int len = strlen(s) + 1;
240 tab = *(intptr_t**)tab_ptr;
241 if ((nb & (nb - 1)) == 0) {
246 tab =
av_realloc(tab, nb_alloc *
sizeof(intptr_t));
247 *(intptr_t**)tab_ptr = tab;
249 tab[nb++] = (intptr_t)elem;
275 uint32_t
a = v << 8 | v >> 16;
276 uint32_t
b = v << 16 | v >> 8;
277 uint32_t
c = v << 24 |
v;
280 uint32_t a = v | v << 24;
281 uint32_t b = v >> 8 | v << 16;
282 uint32_t c = v >> 16 | v << 8;
329 const uint8_t *src = &dst[-back];
334 memset(dst, *src, cnt);
335 }
else if (back == 2) {
337 }
else if (back == 3) {
339 }
else if (back == 4) {
344 while (cnt > blocklen) {
345 memcpy(dst, src, blocklen);
350 memcpy(dst, src, cnt);