[vlc-devel] [PATCH 4/6] live555: Use new instead of calloc

Hugo Beauzée-Luyssen hugo at beauzee.fr
Mon Aug 20 16:29:42 CEST 2018


On Mon, Aug 20, 2018, at 4:18 PM, Rémi Denis-Courmont wrote:
> If you checked that zero init is unnecessary, then this should be fine.
> 
> Le 20 août 2018 15:38:18 GMT+03:00, "Hugo Beauzée-Luyssen" 
> <hugo at beauzee.fr> a écrit :
> >---
> > modules/access/live555.cpp | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> >diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
> >index 0060c24904..8464eb8dc3 100644
> >--- a/modules/access/live555.cpp
> >+++ b/modules/access/live555.cpp
> >@@ -342,12 +342,12 @@ static int  Open ( vlc_object_t *p_this )
> > 
> >     p_demux->pf_demux  = Demux;
> >     p_demux->pf_control= Control;
> >-    p_demux->p_sys     = p_sys = (demux_sys_t*)calloc( 1, sizeof(
> >demux_sys_t ) );
> >+    p_demux->p_sys     = p_sys = new (std::nothrow)demux_sys_t();
> >     if( !p_sys ) return VLC_ENOMEM;
> > 
> >     if( vlc_timer_create(&p_sys->timer, TimeoutPrevention, p_demux) )
> >     {
> >-        free( p_sys );
> >+        delete p_sys;
> >         return VLC_ENOMEM;
> >     }
> > 
> >@@ -506,7 +506,7 @@ static void Close( vlc_object_t *p_this )
> >     vlc_UrlClean( &p_sys->url );
> >     vlc_mutex_destroy(&p_sys->timeout_mutex);
> > 
> >-    free( p_sys );
> >+    delete p_sys;
> > }
> > 
> >static inline Boolean toBool( bool b ) { return b?True:False; } //
> >silly, no?
> >-- 
> >2.18.0
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
> 
> -- 
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser 
> ma brièveté.
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

This will value-initialize all members, which will 0 initialize all non class members (in short), so I don't think it changes anything compared to calloc'ing

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list