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

Michael Niedermayer michael at niedermayer.cc
Thu Jul 28 12:57:25 EEST 2016


On Thu, Jul 28, 2016 at 11:50:47AM +0200, Michael Niedermayer wrote:
> 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

this in fact also doesnt work as description, as it would leave
identifying realloc errors with size 0 impossible


> 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 



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued
-------------- 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/4be04816/attachment.sig>


More information about the ffmpeg-devel mailing list