[FFmpeg-devel] [PATCH 1/4] avformat/hashenc: use an array of hashes

Moritz Barsnick barsnick at gmx.net
Mon Aug 12 15:55:55 EEST 2019


On Sun, Aug 11, 2019 at 15:57:46 +0200, Nicolas George wrote:
> > +    c->hashes = av_malloc_array(1, sizeof(c->hashes));
> > +    if (!c->hashes)
> > +        return AVERROR(ENOMEM);
> > +    res = av_hash_alloc(&c->hashes[0], c->hash_name);
> > +    if (res < 0) {
> > +        av_freep(&c->hashes);
>
> Maybe move all the freing code in a deinit() function?

Sure, I'll have a look how the other muxers do it.

The code is later allocating hashes av_hash_alloc() in a loop over
nb_streams. If this fails (i.e. out of memory) along the way, do I need
to remember how many succeeded before? (See patch 4/4.) Or can I just
av_hash_freep() each one in the array, regardsless?

Grateful for any other reviews,
thanks,
Moritz


More information about the ffmpeg-devel mailing list