[FFmpeg-devel] [PATCH] avutil/mem: fix outdated comment

Michael Niedermayer michael at niedermayer.cc
Thu Jul 28 12:50:47 EEST 2016


On Mon, Jul 18, 2016 at 11:36:49PM +0800, Zhao Zhili wrote:
> ---
>  libavutil/mem.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/mem.h b/libavutil/mem.h
> index d25b322..9dd9099 100644
> --- a/libavutil/mem.h
> +++ b/libavutil/mem.h
> @@ -99,14 +99,14 @@ 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.
> + * If ptr is NULL and size > 0, allocate a new block. The memory block
> pointed
> + * to by ptr won't be freed even when size is zero.

av_realloc() can certainly free the source pointed to
be ptr as it sees fit during reallocation also when the size is 0.

we could document it either as
The behavior with size 0 may be that an allocated array of small size
is returned instead of the null pointer and complete deallocation
or With size 0 an allocated array of minimal size is provided, accesses
into such size 0 array result in undefined behavior.

or similar

question is how much room for changes we want ...


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160728/22159152/attachment.sig>


More information about the ffmpeg-devel mailing list