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 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
@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()
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 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 @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()