X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Fmem.h;h=fb23a690948ad833c5bc3fc3fc19515695751b10;hb=a46e578ddacd680b5b169a70c61032381a1b9f63;hp=a3294690cf97c32bd05a24f8535a77153b729727;hpb=8543575cc4e270b2d53d00ed0d26140a9badc6bd;p=ffmpeg diff --git a/libavutil/mem.h b/libavutil/mem.h index a3294690cf9..fb23a690948 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -122,6 +122,32 @@ void *av_realloc(void *ptr, size_t size) av_alloc_size(2); */ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); +/** + * Allocate or reallocate an array. + * If ptr is NULL and nmemb > 0, allocate a new block. If + * nmemb is zero, free the memory block pointed to by ptr. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @param nmemb Number of elements + * @param size Size of the single element + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be reallocated or the function is used to free the memory block. + */ +av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); + +/** + * Allocate or reallocate an array. + * If *ptr is NULL and nmemb > 0, allocate a new block. If + * nmemb is zero, free the memory block pointed to by ptr. + * @param ptr Pointer to a pointer to a memory block already allocated + * with av_malloc(z)() or av_realloc(), or pointer to a pointer to NULL. + * The pointer is updated on success, or freed on failure. + * @param nmemb Number of elements + * @param size Size of the single element + * @return Zero on success, an AVERROR error code on failure. + */ +av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size); + /** * Free a memory block which has been allocated with av_malloc(z)() or * av_realloc().