* qatar/master: configure: Group math functions into a separate variable avutil/mem: K&R formatting cosmetics avutil/lzo: K&R formatting cosmetics Conflicts: configure libavutil/mem.c Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n1.1
@@ -1263,6 +1263,25 @@ HAVE_LIST_PUB=' | |||||
incompatible_fork_abi | incompatible_fork_abi | ||||
' | ' | ||||
MATH_FUNCS=" | |||||
cbrtf | |||||
exp2 | |||||
exp2f | |||||
isinf | |||||
isnan | |||||
llrint | |||||
llrintf | |||||
log2 | |||||
log2f | |||||
lrint | |||||
lrintf | |||||
rint | |||||
round | |||||
roundf | |||||
trunc | |||||
truncf | |||||
" | |||||
HAVE_LIST=" | HAVE_LIST=" | ||||
$ARCH_EXT_LIST | $ARCH_EXT_LIST | ||||
$(add_suffix _external $ARCH_EXT_LIST) | $(add_suffix _external $ARCH_EXT_LIST) | ||||
@@ -1270,6 +1289,7 @@ HAVE_LIST=" | |||||
$HAVE_LIST_CMDLINE | $HAVE_LIST_CMDLINE | ||||
$HAVE_LIST_PUB | $HAVE_LIST_PUB | ||||
$THREADS_LIST | $THREADS_LIST | ||||
$MATH_FUNCS | |||||
aligned_malloc | aligned_malloc | ||||
aligned_stack | aligned_stack | ||||
alsa_asoundlib_h | alsa_asoundlib_h | ||||
@@ -1280,7 +1300,6 @@ HAVE_LIST=" | |||||
asm_types_h | asm_types_h | ||||
attribute_may_alias | attribute_may_alias | ||||
attribute_packed | attribute_packed | ||||
cbrtf | |||||
clock_gettime | clock_gettime | ||||
closesocket | closesocket | ||||
cmov | cmov | ||||
@@ -1299,8 +1318,6 @@ HAVE_LIST=" | |||||
dxva_h | dxva_h | ||||
ebp_available | ebp_available | ||||
ebx_available | ebx_available | ||||
exp2 | |||||
exp2f | |||||
fast_64bit | fast_64bit | ||||
fast_clz | fast_clz | ||||
fast_cmov | fast_cmov | ||||
@@ -1321,23 +1338,15 @@ HAVE_LIST=" | |||||
inet_aton | inet_aton | ||||
io_h | io_h | ||||
isatty | isatty | ||||
isinf | |||||
isnan | |||||
jack_port_get_latency_range | jack_port_get_latency_range | ||||
kbhit | kbhit | ||||
ldbrx | ldbrx | ||||
libdc1394_1 | libdc1394_1 | ||||
libdc1394_2 | libdc1394_2 | ||||
llrint | |||||
llrintf | |||||
local_aligned_16 | local_aligned_16 | ||||
local_aligned_8 | local_aligned_8 | ||||
localtime_r | localtime_r | ||||
log2 | |||||
log2f | |||||
loongson | loongson | ||||
lrint | |||||
lrintf | |||||
lzo1x_999_compress | lzo1x_999_compress | ||||
machine_ioctl_bt848_h | machine_ioctl_bt848_h | ||||
machine_ioctl_meteor_h | machine_ioctl_meteor_h | ||||
@@ -1358,9 +1367,6 @@ HAVE_LIST=" | |||||
posix_memalign | posix_memalign | ||||
pthread_cancel | pthread_cancel | ||||
rdtsc | rdtsc | ||||
rint | |||||
round | |||||
roundf | |||||
sched_getaffinity | sched_getaffinity | ||||
sdl | sdl | ||||
sdl_video_size | sdl_video_size | ||||
@@ -1396,8 +1402,6 @@ HAVE_LIST=" | |||||
termios_h | termios_h | ||||
texi2html | texi2html | ||||
threads | threads | ||||
trunc | |||||
truncf | |||||
unistd_h | unistd_h | ||||
usleep | usleep | ||||
vfp_args | vfp_args | ||||
@@ -3615,22 +3619,9 @@ check_lib math.h sin -lm && LIBM="-lm" | |||||
disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd | disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd | ||||
enabled vaapi && require vaapi va/va.h vaInitialize -lva | enabled vaapi && require vaapi va/va.h vaInitialize -lva | ||||
check_mathfunc cbrtf | |||||
check_mathfunc exp2 | |||||
check_mathfunc exp2f | |||||
check_mathfunc isinf | |||||
check_mathfunc isnan | |||||
check_mathfunc llrint | |||||
check_mathfunc llrintf | |||||
check_mathfunc log2 | |||||
check_mathfunc log2f | |||||
check_mathfunc lrint | |||||
check_mathfunc lrintf | |||||
check_mathfunc rint | |||||
check_mathfunc round | |||||
check_mathfunc roundf | |||||
check_mathfunc trunc | |||||
check_mathfunc truncf | |||||
for func in $MATH_FUNCS; do | |||||
check_mathfunc $func | |||||
done | |||||
# these are off by default, so fail if requested and not available | # these are off by default, so fail if requested and not available | ||||
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32 | enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32 | ||||
@@ -29,6 +29,7 @@ | |||||
#define OUTBUF_PADDED 1 | #define OUTBUF_PADDED 1 | ||||
/// Define if we may read up to 8 bytes beyond the input buffer. | /// Define if we may read up to 8 bytes beyond the input buffer. | ||||
#define INBUF_PADDED 1 | #define INBUF_PADDED 1 | ||||
typedef struct LZOContext { | typedef struct LZOContext { | ||||
const uint8_t *in, *in_end; | const uint8_t *in, *in_end; | ||||
uint8_t *out_start, *out, *out_end; | uint8_t *out_start, *out, *out_end; | ||||
@@ -39,7 +40,8 @@ typedef struct LZOContext { | |||||
* @brief Reads one byte from the input buffer, avoiding an overrun. | * @brief Reads one byte from the input buffer, avoiding an overrun. | ||||
* @return byte read | * @return byte read | ||||
*/ | */ | ||||
static inline int get_byte(LZOContext *c) { | |||||
static inline int get_byte(LZOContext *c) | |||||
{ | |||||
if (c->in < c->in_end) | if (c->in < c->in_end) | ||||
return *c->in++; | return *c->in++; | ||||
c->error |= AV_LZO_INPUT_DEPLETED; | c->error |= AV_LZO_INPUT_DEPLETED; | ||||
@@ -58,10 +60,12 @@ static inline int get_byte(LZOContext *c) { | |||||
* @param mask bits used from x | * @param mask bits used from x | ||||
* @return decoded length value | * @return decoded length value | ||||
*/ | */ | ||||
static inline int get_len(LZOContext *c, int x, int mask) { | |||||
static inline int get_len(LZOContext *c, int x, int mask) | |||||
{ | |||||
int cnt = x & mask; | int cnt = x & mask; | ||||
if (!cnt) { | if (!cnt) { | ||||
while (!(x = get_byte(c))) cnt += 255; | |||||
while (!(x = get_byte(c))) | |||||
cnt += 255; | |||||
cnt += mask + x; | cnt += mask + x; | ||||
} | } | ||||
return cnt; | return cnt; | ||||
@@ -84,15 +88,16 @@ static inline int get_len(LZOContext *c, int x, int mask) { | |||||
* @brief Copies bytes from input to output buffer with checking. | * @brief Copies bytes from input to output buffer with checking. | ||||
* @param cnt number of bytes to copy, must be >= 0 | * @param cnt number of bytes to copy, must be >= 0 | ||||
*/ | */ | ||||
static inline void copy(LZOContext *c, int cnt) { | |||||
static inline void copy(LZOContext *c, int cnt) | |||||
{ | |||||
register const uint8_t *src = c->in; | register const uint8_t *src = c->in; | ||||
register uint8_t *dst = c->out; | |||||
register uint8_t *dst = c->out; | |||||
if (cnt > c->in_end - src) { | if (cnt > c->in_end - src) { | ||||
cnt = FFMAX(c->in_end - src, 0); | |||||
cnt = FFMAX(c->in_end - src, 0); | |||||
c->error |= AV_LZO_INPUT_DEPLETED; | c->error |= AV_LZO_INPUT_DEPLETED; | ||||
} | } | ||||
if (cnt > c->out_end - dst) { | if (cnt > c->out_end - dst) { | ||||
cnt = FFMAX(c->out_end - dst, 0); | |||||
cnt = FFMAX(c->out_end - dst, 0); | |||||
c->error |= AV_LZO_OUTPUT_FULL; | c->error |= AV_LZO_OUTPUT_FULL; | ||||
} | } | ||||
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) | #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) | ||||
@@ -102,8 +107,8 @@ static inline void copy(LZOContext *c, int cnt) { | |||||
cnt -= 4; | cnt -= 4; | ||||
if (cnt > 0) | if (cnt > 0) | ||||
#endif | #endif | ||||
memcpy(dst, src, cnt); | |||||
c->in = src + cnt; | |||||
memcpy(dst, src, cnt); | |||||
c->in = src + cnt; | |||||
c->out = dst + cnt; | c->out = dst + cnt; | ||||
} | } | ||||
@@ -117,22 +122,24 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); | |||||
* cnt > back is valid, this will copy the bytes we just copied, | * cnt > back is valid, this will copy the bytes we just copied, | ||||
* thus creating a repeating pattern with a period length of back. | * thus creating a repeating pattern with a period length of back. | ||||
*/ | */ | ||||
static inline void copy_backptr(LZOContext *c, int back, int cnt) { | |||||
static inline void copy_backptr(LZOContext *c, int back, int cnt) | |||||
{ | |||||
register const uint8_t *src = &c->out[-back]; | register const uint8_t *src = &c->out[-back]; | ||||
register uint8_t *dst = c->out; | |||||
register uint8_t *dst = c->out; | |||||
if (src < c->out_start || src > dst) { | if (src < c->out_start || src > dst) { | ||||
c->error |= AV_LZO_INVALID_BACKPTR; | c->error |= AV_LZO_INVALID_BACKPTR; | ||||
return; | return; | ||||
} | } | ||||
if (cnt > c->out_end - dst) { | if (cnt > c->out_end - dst) { | ||||
cnt = FFMAX(c->out_end - dst, 0); | |||||
cnt = FFMAX(c->out_end - dst, 0); | |||||
c->error |= AV_LZO_OUTPUT_FULL; | c->error |= AV_LZO_OUTPUT_FULL; | ||||
} | } | ||||
memcpy_backptr(dst, back, cnt); | memcpy_backptr(dst, back, cnt); | ||||
c->out = dst + cnt; | c->out = dst + cnt; | ||||
} | } | ||||
static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { | |||||
static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) | |||||
{ | |||||
const uint8_t *src = &dst[-back]; | const uint8_t *src = &dst[-back]; | ||||
if (back <= 1) { | if (back <= 1) { | ||||
memset(dst, *src, cnt); | memset(dst, *src, cnt); | ||||
@@ -157,8 +164,8 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { | |||||
int blocklen = back; | int blocklen = back; | ||||
while (cnt > blocklen) { | while (cnt > blocklen) { | ||||
memcpy(dst, src, blocklen); | memcpy(dst, src, blocklen); | ||||
dst += blocklen; | |||||
cnt -= blocklen; | |||||
dst += blocklen; | |||||
cnt -= blocklen; | |||||
blocklen <<= 1; | blocklen <<= 1; | ||||
} | } | ||||
memcpy(dst, src, cnt); | memcpy(dst, src, cnt); | ||||
@@ -166,12 +173,14 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { | |||||
} | } | ||||
} | } | ||||
void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { | |||||
void av_memcpy_backptr(uint8_t *dst, int back, int cnt) | |||||
{ | |||||
memcpy_backptr(dst, back, cnt); | memcpy_backptr(dst, back, cnt); | ||||
} | } | ||||
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
int state= 0; | |||||
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) | |||||
{ | |||||
int state = 0; | |||||
int x; | int x; | ||||
LZOContext c; | LZOContext c; | ||||
if (*outlen <= 0 || *inlen <= 0) { | if (*outlen <= 0 || *inlen <= 0) { | ||||
@@ -182,16 +191,17 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
res |= AV_LZO_INPUT_DEPLETED; | res |= AV_LZO_INPUT_DEPLETED; | ||||
return res; | return res; | ||||
} | } | ||||
c.in = in; | |||||
c.in_end = (const uint8_t *)in + *inlen; | |||||
c.out = c.out_start = out; | |||||
c.out_end = (uint8_t *)out + * outlen; | |||||
c.error = 0; | |||||
x = GETB(c); | |||||
c.in = in; | |||||
c.in_end = (const uint8_t *)in + *inlen; | |||||
c.out = c.out_start = out; | |||||
c.out_end = (uint8_t *)out + *outlen; | |||||
c.error = 0; | |||||
x = GETB(c); | |||||
if (x > 17) { | if (x > 17) { | ||||
copy(&c, x - 17); | copy(&c, x - 17); | ||||
x = GETB(c); | x = GETB(c); | ||||
if (x < 16) c.error |= AV_LZO_ERROR; | |||||
if (x < 16) | |||||
c.error |= AV_LZO_ERROR; | |||||
} | } | ||||
if (c.in > c.in_end) | if (c.in > c.in_end) | ||||
c.error |= AV_LZO_INPUT_DEPLETED; | c.error |= AV_LZO_INPUT_DEPLETED; | ||||
@@ -199,16 +209,16 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
int cnt, back; | int cnt, back; | ||||
if (x > 15) { | if (x > 15) { | ||||
if (x > 63) { | if (x > 63) { | ||||
cnt = (x >> 5) - 1; | |||||
cnt = (x >> 5) - 1; | |||||
back = (GETB(c) << 3) + ((x >> 2) & 7) + 1; | back = (GETB(c) << 3) + ((x >> 2) & 7) + 1; | ||||
} else if (x > 31) { | } else if (x > 31) { | ||||
cnt = get_len(&c, x, 31); | |||||
x = GETB(c); | |||||
cnt = get_len(&c, x, 31); | |||||
x = GETB(c); | |||||
back = (GETB(c) << 6) + (x >> 2) + 1; | back = (GETB(c) << 6) + (x >> 2) + 1; | ||||
} else { | } else { | ||||
cnt = get_len(&c, x, 7); | |||||
back = (1 << 14) + ((x & 8) << 11); | |||||
x = GETB(c); | |||||
cnt = get_len(&c, x, 7); | |||||
back = (1 << 14) + ((x & 8) << 11); | |||||
x = GETB(c); | |||||
back += (GETB(c) << 6) + (x >> 2); | back += (GETB(c) << 6) + (x >> 2); | ||||
if (back == (1 << 14)) { | if (back == (1 << 14)) { | ||||
if (cnt != 1) | if (cnt != 1) | ||||
@@ -216,21 +226,21 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} else if(!state){ | |||||
cnt = get_len(&c, x, 15); | |||||
copy(&c, cnt + 3); | |||||
x = GETB(c); | |||||
if (x > 15) | |||||
continue; | |||||
cnt = 1; | |||||
back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; | |||||
} else if (!state) { | |||||
cnt = get_len(&c, x, 15); | |||||
copy(&c, cnt + 3); | |||||
x = GETB(c); | |||||
if (x > 15) | |||||
continue; | |||||
cnt = 1; | |||||
back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; | |||||
} else { | } else { | ||||
cnt = 0; | |||||
back = (GETB(c) << 2) + (x >> 2) + 1; | |||||
cnt = 0; | |||||
back = (GETB(c) << 2) + (x >> 2) + 1; | |||||
} | } | ||||
copy_backptr(&c, back, cnt + 2); | copy_backptr(&c, back, cnt + 2); | ||||
state= | |||||
cnt = x & 3; | |||||
state = | |||||
cnt = x & 3; | |||||
copy(&c, cnt); | copy(&c, cnt); | ||||
x = GETB(c); | x = GETB(c); | ||||
} | } | ||||
@@ -32,18 +32,18 @@ | |||||
#include <stdint.h> | #include <stdint.h> | ||||
/** @name Error flags returned by av_lzo1x_decode | /** @name Error flags returned by av_lzo1x_decode | ||||
* @{ */ | |||||
* @{ */ | |||||
/// end of the input buffer reached before decoding finished | /// end of the input buffer reached before decoding finished | ||||
#define AV_LZO_INPUT_DEPLETED 1 | |||||
#define AV_LZO_INPUT_DEPLETED 1 | |||||
/// decoded data did not fit into output buffer | /// decoded data did not fit into output buffer | ||||
#define AV_LZO_OUTPUT_FULL 2 | |||||
#define AV_LZO_OUTPUT_FULL 2 | |||||
/// a reference to previously decoded data was wrong | /// a reference to previously decoded data was wrong | ||||
#define AV_LZO_INVALID_BACKPTR 4 | #define AV_LZO_INVALID_BACKPTR 4 | ||||
/// a non-specific error in the compressed bitstream | /// a non-specific error in the compressed bitstream | ||||
#define AV_LZO_ERROR 8 | |||||
#define AV_LZO_ERROR 8 | |||||
/** @} */ | /** @} */ | ||||
#define AV_LZO_INPUT_PADDING 8 | |||||
#define AV_LZO_INPUT_PADDING 8 | |||||
#define AV_LZO_OUTPUT_PADDING 12 | #define AV_LZO_OUTPUT_PADDING 12 | ||||
/** | /** | ||||
@@ -80,47 +80,47 @@ void *av_malloc(size_t size) | |||||
#endif | #endif | ||||
/* let's disallow possible ambiguous cases */ | /* let's disallow possible ambiguous cases */ | ||||
if (size > (max_alloc_size-32)) | |||||
if (size > (max_alloc_size - 32)) | |||||
return NULL; | return NULL; | ||||
#if CONFIG_MEMALIGN_HACK | #if CONFIG_MEMALIGN_HACK | ||||
ptr = malloc(size+ALIGN); | |||||
if(!ptr) | |||||
ptr = malloc(size + ALIGN); | |||||
if (!ptr) | |||||
return ptr; | return ptr; | ||||
diff= ((-(long)ptr - 1)&(ALIGN-1)) + 1; | |||||
ptr = (char*)ptr + diff; | |||||
((char*)ptr)[-1]= diff; | |||||
diff = ((-(long)ptr - 1)&(ALIGN - 1)) + 1; | |||||
ptr = (char *)ptr + diff; | |||||
((char *)ptr)[-1] = diff; | |||||
#elif HAVE_POSIX_MEMALIGN | #elif HAVE_POSIX_MEMALIGN | ||||
if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation | if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation | ||||
if (posix_memalign(&ptr,ALIGN,size)) | |||||
if (posix_memalign(&ptr, ALIGN, size)) | |||||
ptr = NULL; | ptr = NULL; | ||||
#elif HAVE_ALIGNED_MALLOC | #elif HAVE_ALIGNED_MALLOC | ||||
ptr = _aligned_malloc(size, ALIGN); | ptr = _aligned_malloc(size, ALIGN); | ||||
#elif HAVE_MEMALIGN | #elif HAVE_MEMALIGN | ||||
ptr = memalign(ALIGN,size); | |||||
ptr = memalign(ALIGN, size); | |||||
/* Why 64? | /* Why 64? | ||||
Indeed, we should align it: | |||||
on 4 for 386 | |||||
on 16 for 486 | |||||
on 32 for 586, PPro - K6-III | |||||
on 64 for K7 (maybe for P3 too). | |||||
Because L1 and L2 caches are aligned on those values. | |||||
But I don't want to code such logic here! | |||||
* Indeed, we should align it: | |||||
* on 4 for 386 | |||||
* on 16 for 486 | |||||
* on 32 for 586, PPro - K6-III | |||||
* on 64 for K7 (maybe for P3 too). | |||||
* Because L1 and L2 caches are aligned on those values. | |||||
* But I don't want to code such logic here! | |||||
*/ | */ | ||||
/* Why 32? | |||||
For AVX ASM. SSE / NEON needs only 16. | |||||
Why not larger? Because I did not see a difference in benchmarks ... | |||||
/* Why 32? | |||||
* For AVX ASM. SSE / NEON needs only 16. | |||||
* Why not larger? Because I did not see a difference in benchmarks ... | |||||
*/ | */ | ||||
/* benchmarks with P3 | |||||
memalign(64)+1 3071,3051,3032 | |||||
memalign(64)+2 3051,3032,3041 | |||||
memalign(64)+4 2911,2896,2915 | |||||
memalign(64)+8 2545,2554,2550 | |||||
memalign(64)+16 2543,2572,2563 | |||||
memalign(64)+32 2546,2545,2571 | |||||
memalign(64)+64 2570,2533,2558 | |||||
BTW, malloc seems to do 8-byte alignment by default here. | |||||
/* benchmarks with P3 | |||||
* memalign(64) + 1 3071, 3051, 3032 | |||||
* memalign(64) + 2 3051, 3032, 3041 | |||||
* memalign(64) + 4 2911, 2896, 2915 | |||||
* memalign(64) + 8 2545, 2554, 2550 | |||||
* memalign(64) + 16 2543, 2572, 2563 | |||||
* memalign(64) + 32 2546, 2545, 2571 | |||||
* memalign(64) + 64 2570, 2533, 2558 | |||||
* | |||||
* BTW, malloc seems to do 8-byte alignment by default here. | |||||
*/ | */ | ||||
#else | #else | ||||
ptr = malloc(size); | ptr = malloc(size); | ||||
@@ -143,15 +143,17 @@ void *av_realloc(void *ptr, size_t size) | |||||
#endif | #endif | ||||
/* let's disallow possible ambiguous cases */ | /* let's disallow possible ambiguous cases */ | ||||
if (size > (max_alloc_size-32)) | |||||
if (size > (max_alloc_size - 32)) | |||||
return NULL; | return NULL; | ||||
#if CONFIG_MEMALIGN_HACK | #if CONFIG_MEMALIGN_HACK | ||||
//FIXME this isn't aligned correctly, though it probably isn't needed | //FIXME this isn't aligned correctly, though it probably isn't needed | ||||
if(!ptr) return av_malloc(size); | |||||
diff= ((char*)ptr)[-1]; | |||||
ptr= realloc((char*)ptr - diff, size + diff); | |||||
if(ptr) ptr = (char*)ptr + diff; | |||||
if (!ptr) | |||||
return av_malloc(size); | |||||
diff = ((char *)ptr)[-1]; | |||||
ptr = realloc((char *)ptr - diff, size + diff); | |||||
if (ptr) | |||||
ptr = (char *)ptr + diff; | |||||
return ptr; | return ptr; | ||||
#elif HAVE_ALIGNED_MALLOC | #elif HAVE_ALIGNED_MALLOC | ||||
return _aligned_realloc(ptr, size + !size, ALIGN); | return _aligned_realloc(ptr, size + !size, ALIGN); | ||||
@@ -179,7 +181,7 @@ void av_free(void *ptr) | |||||
{ | { | ||||
#if CONFIG_MEMALIGN_HACK | #if CONFIG_MEMALIGN_HACK | ||||
if (ptr) | if (ptr) | ||||
free((char*)ptr - ((char*)ptr)[-1]); | |||||
free((char *)ptr - ((char *)ptr)[-1]); | |||||
#elif HAVE_ALIGNED_MALLOC | #elif HAVE_ALIGNED_MALLOC | ||||
_aligned_free(ptr); | _aligned_free(ptr); | ||||
#else | #else | ||||
@@ -189,7 +191,7 @@ void av_free(void *ptr) | |||||
void av_freep(void *arg) | void av_freep(void *arg) | ||||
{ | { | ||||
void **ptr= (void**)arg; | |||||
void **ptr = (void **)arg; | |||||
av_free(*ptr); | av_free(*ptr); | ||||
*ptr = NULL; | *ptr = NULL; | ||||
} | } | ||||
@@ -211,8 +213,8 @@ void *av_calloc(size_t nmemb, size_t size) | |||||
char *av_strdup(const char *s) | char *av_strdup(const char *s) | ||||
{ | { | ||||
char *ptr= NULL; | |||||
if(s){ | |||||
char *ptr = NULL; | |||||
if (s) { | |||||
int len = strlen(s) + 1; | int len = strlen(s) + 1; | ||||
ptr = av_malloc(len); | ptr = av_malloc(len); | ||||
if (ptr) | if (ptr) | ||||
@@ -90,7 +90,7 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); | |||||
* be allocated. | * be allocated. | ||||
* @see av_malloc() | * @see av_malloc() | ||||
*/ | */ | ||||
av_alloc_size(1,2) static inline void *av_malloc_array(size_t nmemb, size_t size) | |||||
av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) | |||||
{ | { | ||||
if (size <= 0 || nmemb >= INT_MAX / size) | if (size <= 0 || nmemb >= INT_MAX / size) | ||||
return NULL; | return NULL; | ||||
@@ -163,7 +163,7 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; | |||||
* @see av_mallocz() | * @see av_mallocz() | ||||
* @see av_malloc_array() | * @see av_malloc_array() | ||||
*/ | */ | ||||
av_alloc_size(1,2) static inline void *av_mallocz_array(size_t nmemb, size_t size) | |||||
av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) | |||||
{ | { | ||||
if (size <= 0 || nmemb >= INT_MAX / size) | if (size <= 0 || nmemb >= INT_MAX / size) | ||||
return NULL; | return NULL; | ||||