From cce3e0a49f0dd030262c28d9c53de0bd2fd909c4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 27 Oct 2013 22:21:59 +0100 Subject: Move av_fast_{m,re}alloc from lavc to lavu. --- libavutil/mem.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libavutil/mem.h') diff --git a/libavutil/mem.h b/libavutil/mem.h index 99dc4cc156..4a5e362cec 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -237,6 +237,27 @@ void av_freep(void *ptr); */ void av_memcpy_backptr(uint8_t *dst, int back, int cnt); +/** + * Reallocate the given block if it is not large enough, otherwise do nothing. + * + * @see av_realloc + */ +void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * 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. + * + * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer + * @param size size of the buffer *ptr points to + * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and + * *size 0 if an error occurred. + */ +void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); + /** * @} */ -- cgit v1.2.3