[FFmpeg-devel] [PATCH 2/3] lavc: add av_fast_padded_mallocz

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jul 10 22:14:15 CEST 2012


On Tue, Jul 10, 2012 at 02:46:05PM +0000, Paul B Mahol wrote:
> On 7/10/12, Reimar Doeffinger <Reimar.Doeffinger at gmx.de> wrote:
> >
> >
> > On 10 Jul 2012, at 05:53, Paul B Mahol <onemda at gmail.com> wrote:
> >
> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> ---
> >> libavcodec/avcodec.h |    6 ++++++
> >> libavcodec/utils.c   |   12 ++++++++++++
> >> 2 files changed, 18 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index c850963..80bd75e 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -4602,6 +4602,12 @@ void av_fast_malloc(void *ptr, unsigned int *size,
> >> size_t min_size);
> >> void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t
> >> min_size);
> >>
> >> /**
> >> + * Same behaviour av_fast_padded_malloc except that buffer will always
> >> + * be 0-initialized after call.
> >
> > Huh? I don't think that's what it does, it does not always initialize to 0,
> > also I think it misses a check for allocation failure.
> 
> You are wrong in both cases.

Yes, I read it the wrong way round, sorry.
Should be ok. I guess if everyone used the buffer correctly
it should not be necessary to memset the padding, but that's
an optimization probably not worth the risk.
(I wonder if for debugging it would be good to have optional
code in places like this to check that the padding is still all-0
as it should be).


More information about the ffmpeg-devel mailing list