av_fast_malloc

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, &current_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 current size of buffer *ptr. *size is changed to min_size in case of success or 0 in case of failure @paramin min_size New size of buffer *ptr @see av_realloc() @see av_fast_mallocz()

extern (C) @nogc nothrow
void
av_fast_malloc
(
void* ptr
,
uint* size
,
size_t min_size
)

Meta