Allocate a buffer, reusing the given one if large enough.
Contrary to av_fast_realloc(), the current buffer contents might not be
preserved and on error the old buffer is freed, thus no special handling to
avoid memleaks is necessary.
*ptr is allowed to be NULL, in which case allocation always happens if
size_needed is greater than 0.
@param[in,out] ptr Pointer to pointer to an already allocated buffer.
*ptr will be overwritten with pointer to new
buffer on success or NULL on failure
@param[in,out] size Pointer to the size of buffer *ptr. *size is
updated to the new allocated size, in particular 0
in case of failure.
@paramin min_size Desired minimal size of buffer *ptr
@see av_realloc()
@see av_fast_mallocz()
Allocate a buffer, reusing the given one if large enough.
Contrary to av_fast_realloc(), the current buffer contents might not be preserved and on error the old buffer is freed, thus no special handling to avoid memleaks is necessary.
*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.
@code{.c} uint8_t *buf = ...; av_fast_malloc(&buf, ¤t_size, size_needed); if (!buf) { // Allocation failed; buf already freed return AVERROR(ENOMEM); } @endcode
@param[in,out] ptr Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure @param[in,out] size Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure. @paramin min_size Desired minimal size of buffer *ptr @see av_realloc() @see av_fast_mallocz()