[FFmpeg-cvslog] mem: Document the av_realloc family of functions properly

Clément Bœsch u at pkh.me
Wed Sep 4 20:03:04 CEST 2013


On Wed, Sep 04, 2013 at 02:04:37PM +0200, Luca Barbato wrote:
> ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sun Sep  1 19:46:59 2013 +0200| [b4ec7a5fee644ad9882e10c097817b65447b8e55] | committer: Luca Barbato
> 
> mem: Document the av_realloc family of functions properly
> 
> realloc() does not accept pointers from memalign().
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b4ec7a5fee644ad9882e10c097817b65447b8e55
> ---
> 
>  libavutil/mem.h |   12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/mem.h b/libavutil/mem.h
> index 8a4fcd9..e472a3f 100644
> --- a/libavutil/mem.h
> +++ b/libavutil/mem.h
> @@ -101,8 +101,10 @@ av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t siz
>   * Allocate or reallocate a block of memory.
>   * If ptr is NULL and size > 0, allocate a new block. If
>   * size is zero, free the memory block pointed to by ptr.

> + * @note Pointers provided by av_malloc family of functions cannot be
> + * passed to av_realloc().

Can someone explains to me what the hell that means? Is this a typo?

AFAIK it just means the alignment might not be preserved. What am I
missing?

>   * @param ptr Pointer to a memory block already allocated with
> - * av_malloc(z)() or av_realloc() or NULL.
> + * av_realloc() or NULL.
>   * @param size Size in bytes for the memory block to be allocated or
>   * reallocated.
>   * @return Pointer to a newly reallocated block or NULL if the block
> @@ -115,8 +117,10 @@ void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
>   * 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.
> + * @note Pointers provided by av_malloc family of functions cannot be
> + * passed to av_realloc_array().
>   * @param ptr Pointer to a memory block already allocated with
> - * av_malloc(z)() or av_realloc() or NULL.
> + * 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
> @@ -128,8 +132,10 @@ 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.
> + * @note Pointers provided by av_malloc family of functions cannot be
> + * passed to av_reallocp_array().
>   * @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.
> + * with 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
> 

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20130904/cfde8aa3/attachment.asc>


More information about the ffmpeg-cvslog mailing list