MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_fast_realloc

Function av_fast_realloc

libavutil/mem.c:497–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
498{
499 size_t max_size;
500
501 if (min_size <= *size)
502 return ptr;
503
504 max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
505 /* *size is an unsigned, so the real maximum is <= UINT_MAX. */
506 max_size = FFMIN(max_size, UINT_MAX);
507
508 if (min_size > max_size) {
509 *size = 0;
510 return NULL;
511 }
512
513 min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size));
514
515 ptr = av_realloc(ptr, min_size);
516 /* we could set this to the unmodified min_size but this is safer
517 * if the user lost the ptr and uses NULL now
518 */
519 if (!ptr)
520 min_size = 0;
521
522 *size = min_size;
523
524 return ptr;
525}
526
527static inline void fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
528{

Callers 15

ff_mms_asf_header_parserFunction · 0.85
ebml_parseFunction · 0.85
update_frag_indexFunction · 0.85
mov_read_sttsFunction · 0.85
mov_read_cttsFunction · 0.85
add_index_entryFunction · 0.85
add_tts_entryFunction · 0.85
mov_merge_tts_dataFunction · 0.85
mov_read_trunFunction · 0.85
mov_read_sencFunction · 0.85
mov_parse_auxiliary_infoFunction · 0.85
mov_read_saioFunction · 0.85

Calls 1

av_reallocFunction · 0.70

Tested by 2

config_outputFunction · 0.68