|
|
|
@ -55,37 +55,17 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op); |
|
|
|
|
static void *codec_mutex; |
|
|
|
|
static void *avformat_mutex; |
|
|
|
|
|
|
|
|
|
void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) |
|
|
|
|
#if FF_API_FAST_MALLOC && CONFIG_SHARED && HAVE_SYMVER |
|
|
|
|
FF_SYMVER(void*, av_fast_realloc, (void *ptr, unsigned int *size, size_t min_size), "LIBAVCODEC_55") |
|
|
|
|
{ |
|
|
|
|
if (min_size < *size) |
|
|
|
|
return ptr; |
|
|
|
|
|
|
|
|
|
min_size = FFMAX(17 * min_size / 16 + 32, min_size); |
|
|
|
|
|
|
|
|
|
ptr = av_realloc(ptr, min_size); |
|
|
|
|
/* we could set this to the unmodified min_size but this is safer
|
|
|
|
|
* if the user lost the ptr and uses NULL now |
|
|
|
|
*/ |
|
|
|
|
if (!ptr) |
|
|
|
|
min_size = 0; |
|
|
|
|
|
|
|
|
|
*size = min_size; |
|
|
|
|
|
|
|
|
|
return ptr; |
|
|
|
|
return av_fast_realloc(ptr, size, min_size); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) |
|
|
|
|
FF_SYMVER(void, av_fast_malloc, (void *ptr, unsigned int *size, size_t min_size), "LIBAVCODEC_55") |
|
|
|
|
{ |
|
|
|
|
void **p = ptr; |
|
|
|
|
if (min_size < *size) |
|
|
|
|
return; |
|
|
|
|
min_size = FFMAX(17 * min_size / 16 + 32, min_size); |
|
|
|
|
av_free(*p); |
|
|
|
|
*p = av_malloc(min_size); |
|
|
|
|
if (!*p) |
|
|
|
|
min_size = 0; |
|
|
|
|
*size = min_size; |
|
|
|
|
av_fast_malloc(ptr, size, min_size); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) |
|
|
|
|
{ |
|
|
|
|