[vlc-devel] [vlc-commits] decoder: add Destroy helper function for decoder owners

Rémi Denis-Courmont remi at remlab.net
Mon Feb 18 17:32:51 CET 2019


> > +void decoder_Destroy( decoder_t **p_dec )
> > +{
> > +    if (*p_dec != NULL)
> > +    {
> > +        decoder_Clean( *p_dec );
> > +        vlc_object_release( *p_dec );
> > +        *p_dec = NULL;
> > +    }
> 
> I really prefer to use a decoder_t * here.
> There is not many functions in VLC that set the pointer to NULL. This will
> add more confusion.
> 
> I really prefer having a crash (via assert/ASAN) when a client is misusing
> an API (calling Destroy with a freed pointer) instead of ignoring it.

+1

We have been through hell with the "defensive programming" BS garbage in the 
past. I don't want to go back there.

-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list