]> git.sesse.net Git - vlc/blobdiff - modules/demux/mjpeg.c
One more removing session. (useless test before a free())
[vlc] / modules / demux / mjpeg.c
index 67824c98027dff6174f5ea4508b0da810b99e7cd..c7096ed2b96bca5b2b06953cdc4f057dad5f0922 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include <vlc/vlc.h>
-#include <vlc/input.h>
+#include <vlc_demux.h>
 
-#include <codecs.h>
+#include <vlc_codecs.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -75,7 +78,7 @@ struct demux_sys_t
     mtime_t         i_frame_length;
     char            *psz_separator;
     int             i_frame_size_estimate;
-    uint8_t         *p_peek;
+    const uint8_t   *p_peek;
     int             i_data_peeked;
 };
 
@@ -118,7 +121,7 @@ static vlc_bool_t Peek( demux_t *p_demux, vlc_bool_t b_first )
 static char* GetLine( demux_t *p_demux, int *p_pos )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    uint8_t     *p_buf;
+    const uint8_t *p_buf;
     int         i_size;
     int         i;
     char        *p_line;
@@ -202,7 +205,9 @@ static vlc_bool_t CheckMimeHeader( demux_t *p_demux, int *p_header_size )
         *p_header_size = -3;
         return VLC_FALSE;
     }
-    if( NULL == p_sys->psz_separator )
+
+    /* Read the separator and remember it if not yet stored */
+    if( p_sys->psz_separator == NULL )
     {
         p_sys->psz_separator = psz_line;
         msg_Dbg( p_demux, "Multipart MIME detected, using separator: %s",
@@ -215,8 +220,9 @@ static vlc_bool_t CheckMimeHeader( demux_t *p_demux, int *p_header_size )
             msg_Warn( p_demux, "separator %s does not match %s", psz_line,
                       p_sys->psz_separator );
         }
+        free( psz_line );
     }
-    free( psz_line );
+
     psz_line = GetLine( p_demux, &i_pos );
     while( psz_line && *psz_line )
     {
@@ -298,7 +304,6 @@ static int Open( vlc_object_t * p_this )
     int         i_size;
     int         b_matched = VLC_FALSE;
     vlc_value_t val;
-    char *psz_ext;
 
     p_demux->pf_control = Control;
     p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
@@ -340,9 +345,8 @@ static int Open( vlc_object_t * p_this )
     /* Check for jpeg file extension */
     p_sys->b_still = VLC_FALSE;
     p_sys->i_still_end = 0;
-    psz_ext = strrchr( p_demux->psz_path, '.' );
-    if( psz_ext && ( !strcasecmp( psz_ext, ".jpeg" ) ||
-                     !strcasecmp( psz_ext, ".jpg" ) ) )
+    if( demux2_IsPathExtension( p_demux, ".jpeg" ) ||
+        demux2_IsPathExtension( p_demux, ".jpg" ) )
     {
         p_sys->b_still = VLC_TRUE;
         if( val.f_float)
@@ -507,10 +511,7 @@ 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;
 
-    if( p_sys->psz_separator )
-    {
-        free( p_sys->psz_separator );
-    }
+    free( p_sys->psz_separator );
     free( p_sys );
 }