[FFmpeg-devel] [PATCH 02/21] avcodec/zlib_wrapper: Add wrappers for zlib inflateInit, inflateEnd

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Mar 17 09:29:09 EET 2022


Tomas Härdin:
> ons 2022-03-16 klockan 20:32 +0100 skrev Andreas Rheinhardt:
>> Tomas Härdin:
>>>> +int ff_inflate_init(FFZStream *z, void *logctx)
>>>> +{
>>>> +    z_stream *const zstream = &z->zstream;
>>>> +    int zret;
>>>> +
>>>> +    z->inited = 0;
>>>> +    zstream->next_in  = Z_NULL;
>>>> +    zstream->avail_in = 0;
>>>> +    zstream->zalloc   = Z_NULL;
>>>> +    zstream->zfree    = Z_NULL;
>>>> +    zstream->opaque   = Z_NULL;
>>>
>>> why not bzero()?
>>>
>>> Rest of the patch looks fine
>>>
>>
>> bzero()? You mean memset to zero? The reason that I initialize
>> exactly
>> these fields is because these are exactly the fields required to be
>> initialized by zlib (for inflate; next_in and avail_in are not
>> required
>> to be initialized for deflate): "The fields next_in, avail_in,
>> zalloc,
>> zfree and opaque must be initialized before by the caller." zlib
>> treats
>> all the other fields as uninitialized, so why should we initialize
>> them
>> (Actually reinitialize them -- most FFZStreams are already zeroed
>> initially as part of a codec's private context.)? The way it is done
>> in
>> this patch shows directly which elements zlib expects to be set;
>> setting
>> everything would not achieve the same.
> 
> Right. Looks OK then
> 

Thanks for the review. Will apply this patchset tonight unless there are
objections.

- Andreas


More information about the ffmpeg-devel mailing list