Function rsmpeg::ffi::av_fast_realloc [−][src]
pub unsafe extern "C" fn av_fast_realloc(
ptr: *mut c_void,
size: *mut u32,
min_size: u32
) -> *mut c_void
Expand description
Reallocate the given buffer if it is not large enough, otherwise do nothing.
If the given buffer is NULL
, then a new uninitialized buffer is allocated.
If the given buffer is not large enough, and reallocation fails, NULL
is
returned and *size
is set to 0, but the original buffer is not changed or
freed.
A typical use pattern follows:
@code{.c} uint8_t *buf = …; uint8_t *new_buf = av_fast_realloc(buf, ¤t_size, size_needed); if (!new_buf) { // Allocation failed; clean up original buffer av_freep(&buf); return AVERROR(ENOMEM); } @endcode
@param[in,out] ptr Already allocated buffer, or NULL
@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.
@param[in] min_size Desired minimal size of buffer ptr
@return ptr
if the buffer is large enough, a pointer to newly reallocated
buffer if the buffer was not large enough, or NULL
in case of
error
@see av_realloc()
@see av_fast_malloc()