[vlc-commits] mjpeg: use vlc_obj_*(), simplify
Rémi Denis-Courmont
git at videolan.org
Thu May 3 19:13:32 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 3 20:09:47 2018 +0300| [7f59a7ebb7a5936dcfaadaa3308d77fecd866ccd] | committer: Rémi Denis-Courmont
mjpeg: use vlc_obj_*(), simplify
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f59a7ebb7a5936dcfaadaa3308d77fecd866ccd
---
modules/demux/mjpeg.c | 32 +++++++-------------------------
1 file changed, 7 insertions(+), 25 deletions(-)
diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
index dfee7773e9..c8c63b9ab8 100644
--- a/modules/demux/mjpeg.c
+++ b/modules/demux/mjpeg.c
@@ -41,7 +41,6 @@
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
#define FPS_TEXT N_("Frames per Second")
#define FPS_LONGTEXT N_("This is the desired frame rate when " \
@@ -52,7 +51,7 @@ vlc_module_begin ()
set_shortname( "MJPEG")
set_description( N_("M-JPEG camera demuxer") )
set_capability( "demux", 5 )
- set_callbacks( Open, Close )
+ set_callbacks( Open, NULL )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_DEMUX )
add_float( "mjpeg-fps", 0.0, FPS_TEXT, FPS_LONGTEXT, false )
@@ -305,7 +304,7 @@ static int Open( vlc_object_t * p_this )
// let avformat handle this case
return VLC_EGENERIC;
- demux_sys_t *p_sys = malloc( sizeof( demux_sys_t ) );
+ demux_sys_t *p_sys = vlc_obj_malloc( p_this, sizeof (*p_sys) );
if( unlikely(p_sys == NULL) )
return VLC_ENOMEM;
@@ -333,11 +332,11 @@ static int Open( vlc_object_t * p_this )
boundary[len-1] = '\0';
boundary++;
}
- p_sys->psz_separator = strdup( boundary );
+ p_sys->psz_separator = vlc_obj_strdup( p_this, boundary );
if( !p_sys->psz_separator )
{
free( content_type );
- goto error;
+ return VLC_ENOMEM;
}
}
free( content_type );
@@ -348,7 +347,7 @@ static int Open( vlc_object_t * p_this )
{
p_demux->pf_demux = MimeDemux;
if( vlc_stream_Read( p_demux->s, NULL, i_size ) < i_size )
- goto error;
+ return VLC_EGENERIC;
}
else if( i_size == 0 )
{
@@ -361,12 +360,12 @@ static int Open( vlc_object_t * p_this )
}
else
{
- goto error;
+ return VLC_EGENERIC;
}
}
else
{
- goto error;
+ return VLC_EGENERIC;
}
/* Frame rate */
@@ -390,11 +389,6 @@ static int Open( vlc_object_t * p_this )
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );
return VLC_SUCCESS;
-
-error:
- free( p_sys->psz_separator );
- free( p_sys );
- return VLC_EGENERIC;
}
/*****************************************************************************
@@ -537,18 +531,6 @@ static int MimeDemux( demux_t *p_demux )
}
/*****************************************************************************
- * Close: frees unused data
- *****************************************************************************/
-static void Close ( vlc_object_t * p_this )
-{
- demux_t *p_demux = (demux_t*)p_this;
- demux_sys_t *p_sys = p_demux->p_sys;
-
- free( p_sys->psz_separator );
- free( p_sys );
-}
-
-/*****************************************************************************
* Control:
*****************************************************************************/
static int Control( demux_t *p_demux, int i_query, va_list args )
More information about the vlc-commits
mailing list