[MPlayer-cvslog] r32598 - in trunk: asxparser.c codec-cfg.c command.c m_config.c m_option.c mplayer.c playtree.c playtreeparser.c stream/asf_streaming.c stream/audio_in.c stream/cdinfo.c stream/http.c stream/networ...

diego subversion at mplayerhq.hu
Sun Nov 7 13:47:41 CET 2010


Author: diego
Date: Sun Nov  7 13:47:40 2010
New Revision: 32598

Log:
Remove some useless NULL pointer checks before invoking free() on the pointer.
patch by From: Clément Bœsch, ubitux gmail com

Modified:
   trunk/asxparser.c
   trunk/codec-cfg.c
   trunk/command.c
   trunk/m_config.c
   trunk/m_option.c
   trunk/mplayer.c
   trunk/playtree.c
   trunk/playtreeparser.c
   trunk/stream/asf_streaming.c
   trunk/stream/audio_in.c
   trunk/stream/cdinfo.c
   trunk/stream/http.c
   trunk/stream/network.c
   trunk/stream/stream.c
   trunk/stream/stream_cddb.c
   trunk/stream/stream_dvb.c
   trunk/stream/stream_ftp.c
   trunk/stream/stream_netstream.c
   trunk/stream/stream_pvr.c
   trunk/stream/stream_radio.c
   trunk/stream/tv.c
   trunk/stream/tvi_dshow.c
   trunk/stream/tvi_v4l.c
   trunk/stream/tvi_v4l2.c
   trunk/stream/url.c
   trunk/sub/font_load.c
   trunk/sub/font_load_ft.c
   trunk/sub/spudec.c
   trunk/sub/sub_cc.c
   trunk/sub/subreader.c
   trunk/sub/vobsub.c
   trunk/subopt-helper.c
   trunk/xvid_vbr.c

Modified: trunk/asxparser.c
==============================================================================
--- trunk/asxparser.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/asxparser.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -87,7 +87,7 @@ asx_parser_new(void) {
 void
 asx_parser_free(ASX_Parser_t* parser) {
   if(!parser) return;
-  if(parser->ret_stack) free(parser->ret_stack);
+  free(parser->ret_stack);
   free(parser);
 
 }
@@ -289,7 +289,7 @@ asx_get_element(ASX_Parser_t* parser,cha
       if(*ptr3 == '\0') {
         mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing %s element body",parser->line,element);
         free(element);
-        if(attribs) free(attribs);
+        free(attribs);
         return -1;
       }
       if(ptr3[0] == '\n') parser->line++;
@@ -317,7 +317,7 @@ asx_get_element(ASX_Parser_t* parser,cha
       if(ptr4 == NULL || ptr4[1] == '\0') {
         mp_msg(MSGT_PLAYTREE,MSGL_ERR,"At line %d : EOB reached while parsing %s element body",parser->line,element);
         free(element);
-        if(attribs) free(attribs);
+        free(attribs);
         return -1;
       }
       if(ptr4[1] != '/' && strncasecmp(element,ptr4+1,strlen(element)) == 0) {
@@ -406,7 +406,7 @@ asx_parse_param(ASX_Parser_t* parser, ch
   }
   play_tree_set_param(pt,name,val);
   free(name);
-  if(val) free(val);
+  free(val);
 }
 
 static void
@@ -498,7 +498,7 @@ asx_parse_entry(ASX_Parser_t* parser,cha
       nref++;
     } else
       mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element);
-    if(body) free(body);
+    free(body);
     asx_free_attribs(attribs);
   }
 
@@ -564,7 +564,7 @@ asx_parse_repeat(ASX_Parser_t* parser,ch
        asx_parse_param(parser,attribs,repeat);
      } else
        mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element);
-    if(body) free(body);
+     free(body);
      asx_free_attribs(attribs);
   }
 
@@ -649,7 +649,7 @@ asx_parser_build_tree(char* buffer,int d
        }
      } else
        mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element);
-     if(body) free(body);
+     free(body);
      asx_free_attribs(attribs);
   }
 

Modified: trunk/codec-cfg.c
==============================================================================
--- trunk/codec-cfg.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/codec-cfg.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -781,19 +781,13 @@ static void codecs_free(codecs_t* codecs
     int i;
     for ( i = 0; i < count; i++)
         if ( codecs[i].name ) {
-            if( codecs[i].name )
-                free(codecs[i].name);
-            if( codecs[i].info )
-                free(codecs[i].info);
-            if( codecs[i].comment )
-                free(codecs[i].comment);
-            if( codecs[i].dll )
-                free(codecs[i].dll);
-            if( codecs[i].drv )
-                free(codecs[i].drv);
+            free(codecs[i].name);
+            free(codecs[i].info);
+            free(codecs[i].comment);
+            free(codecs[i].dll);
+            free(codecs[i].drv);
         }
-    if (codecs)
-        free(codecs);
+    free(codecs);
 }
 
 void codecs_uninit_free(void) {

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/command.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -512,8 +512,7 @@ static int mp_property_chapter(m_option_
     else
         set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
                     MSGTR_OSDChapter, 0, MSGTR_Unknown);
-    if (chapter_name)
-        free(chapter_name);
+    free(chapter_name);
     return M_PROPERTY_OK;
 }
 
@@ -585,8 +584,7 @@ static int mp_property_angle(m_option_t 
     angle = demuxer_set_angle(mpctx->demuxer, angle);
     set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
                         MSGTR_OSDAngle, angle, angles);
-    if (angle_name)
-        free(angle_name);
+    free(angle_name);
     return M_PROPERTY_OK;
 }
 

Modified: trunk/m_config.c
==============================================================================
--- trunk/m_config.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/m_config.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -208,10 +208,10 @@ m_config_free(m_config_t* config) {
   for(p = config->profiles ; p ; p = pn) {
     pn = p->next;
     free(p->name);
-    if(p->desc) free(p->desc);
+    free(p->desc);
     for(j = 0 ; j < p->num_opts ; j++) {
       free(p->opts[2*j]);
-      if(p->opts[2*j+1]) free(p->opts[2*j+1]);
+      free(p->opts[2*j + 1]);
     }
     free(p->opts);
     free(p);
@@ -459,7 +459,7 @@ m_config_parse_option(const m_config_t *
       free(lst[2*i]);
       free(lst[2*i+1]);
     }
-    if(lst) free(lst);
+    free(lst);
   } else
     r = m_option_parse(co->opt,arg,param,set ? co->slots->data : NULL,config->mode);
 
@@ -566,7 +566,7 @@ m_config_add_profile(m_config_t* config,
 
 void
 m_profile_set_desc(m_profile_t* p, char* desc) {
-  if(p->desc) free(p->desc);
+  free(p->desc);
   p->desc = desc ? strdup(desc) : NULL;
 }
 

Modified: trunk/m_option.c
==============================================================================
--- trunk/m_option.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/m_option.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -400,8 +400,7 @@ static int parse_str(const m_option_t* o
   }
 
   if(dst) {
-    if(VAL(dst))
-      free(VAL(dst));
+    free(VAL(dst));
     VAL(dst) = strdup(param);
   }
 
@@ -416,7 +415,7 @@ static char* print_str(const m_option_t*
 static void copy_str(const m_option_t* opt,void* dst, const void* src) {
   if(dst && src) {
 #ifndef NO_FREE
-    if(VAL(dst)) free(VAL(dst)); //FIXME!!!
+    free(VAL(dst)); //FIXME!!!
 #endif
     VAL(dst) = VAL(src) ? strdup(VAL(src)) : NULL;
   }
@@ -531,7 +530,7 @@ static int str_list_del(char** del, int 
   free(del);
 
   if(s == 0) {
-    if(lst) free(lst);
+    free(lst);
     VAL(dst) = NULL;
     return 1;
   }
@@ -544,7 +543,7 @@ static int str_list_del(char** del, int 
   }
   d[s] = NULL;
 
-  if(lst) free(lst);
+  free(lst);
   VAL(dst) = d;
 
   return 1;
@@ -737,7 +736,7 @@ static void free_func_pf(void* src) {
   while(s) {
     n = s->next;
     free(s->name);
-    if(s->param) free(s->param);
+    free(s->param);
     free(s);
     s = n;
   }

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/mplayer.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -599,7 +599,7 @@ static void print_file_properties(const 
 static void mp_dvdnav_context_free(MPContext *ctx){
     if (ctx->nav_smpi) free_mp_image(ctx->nav_smpi);
     ctx->nav_smpi = NULL;
-    if (ctx->nav_buffer) free(ctx->nav_buffer);
+    free(ctx->nav_buffer);
     ctx->nav_buffer = NULL;
     ctx->nav_start = NULL;
     ctx->nav_in_size = 0;
@@ -760,7 +760,7 @@ void exit_player_with_rc(enum exit_reaso
   mpctx->playtree = NULL;
 
 
-  if(edl_records != NULL) free(edl_records); // free mem allocated for EDL
+  free(edl_records); // free mem allocated for EDL
   edl_records = NULL;
   switch(how) {
   case EXIT_QUIT:
@@ -2037,8 +2037,7 @@ static void mp_dvdnav_save_smpi(int in_s
     if (mpctx->stream->type != STREAMTYPE_DVDNAV)
         return;
 
-    if (mpctx->nav_buffer)
-        free(mpctx->nav_buffer);
+    free(mpctx->nav_buffer);
 
     mpctx->nav_buffer = malloc(in_size);
     mpctx->nav_start = start;
@@ -3947,8 +3946,7 @@ if(step_sec>0) {
   while( !brk_cmd && (cmd = mp_input_get_cmd(0,0,0)) != NULL) {
       brk_cmd = run_command(mpctx, cmd);
       if (cmd->id == MP_CMD_EDL_LOADFILE) {
-          if (edl_filename)
-              free(edl_filename);
+          free(edl_filename);
           edl_filename = strdup(cmd->args[0].v.s);
           if (edl_filename)
               edl_loadfile();

Modified: trunk/playtree.c
==============================================================================
--- trunk/playtree.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/playtree.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -68,7 +68,7 @@ play_tree_free(play_tree_t* pt, int chil
   for(iter = pt->child ; iter != NULL ; iter = iter->next)
     iter->parent = NULL;
 
-  //if(pt->params) free(pt->params);
+  //free(pt->params);
   if(pt->files) {
     int i;
     for(i = 0 ; pt->files[i] != NULL ; i++)
@@ -384,8 +384,8 @@ play_tree_unset_param(play_tree_t* pt, c
   if(ni < 0)
     return 0;
 
-  if(pt->params[ni].name) free(pt->params[ni].name);
-  if(pt->params[ni].value) free(pt->params[ni].value);
+  free(pt->params[ni].name);
+  free(pt->params[ni].value);
 
   if(n > 1) {
     memmove(&pt->params[ni],&pt->params[ni+1],(n-ni)*sizeof(play_tree_param_t));

Modified: trunk/playtreeparser.c
==============================================================================
--- trunk/playtreeparser.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/playtreeparser.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -355,14 +355,9 @@ parse_pls(play_tree_parser_t* p) {
 	list = entry;
       last_entry = entry;
     }
-    if(entries[num].title) {
-      // When we have info in playtree we add this info
-      free(entries[num].title);
-    }
-    if(entries[num].length) {
-      // When we have info in playtree we add this info
-      free(entries[num].length);
-    }
+    // When we have info in playtree we add these info
+    free(entries[num].title);
+    free(entries[num].length);
   }
 
   free(entries);
@@ -518,10 +513,8 @@ parse_smil(play_tree_parser_t* p) {
   line = NULL;
   do {
     strstrip(src_line);
-    if (line) {
-      free(line);
-      line = NULL;
-    }
+    free(line);
+    line = NULL;
     /* If we're parsing smil over realrtsp and this is not the last packet and
      * this is the last line in the packet (terminating with ") ) we must get
      * the next line, strip the header, and concatenate it to the current line.
@@ -601,8 +594,7 @@ parse_smil(play_tree_parser_t* p) {
    }
   } while((src_line = play_tree_parser_get_line(p)) != NULL);
 
-  if (line)
-    free(line);
+  free(line);
 
   if(!list) return NULL; // Nothing found
 
@@ -810,8 +802,8 @@ play_tree_parser_free(play_tree_parser_t
   assert(p != NULL);
 #endif
 
-  if(p->buffer) free(p->buffer);
-  if(p->line) free(p->line);
+  free(p->buffer);
+  free(p->line);
   free(p);
 }
 

Modified: trunk/stream/asf_streaming.c
==============================================================================
--- trunk/stream/asf_streaming.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/asf_streaming.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -400,9 +400,9 @@ static int asf_streaming_parse_header(in
 
 len_err_out:
   mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MPDEMUX_ASF_InvalidLenInHeader);
-  if (buffer) free(buffer);
-  if (v_rates) free(v_rates);
-  if (a_rates) free(a_rates);
+  free(buffer);
+  free(v_rates);
+  free(a_rates);
   return -1;
 }
 

Modified: trunk/stream/audio_in.c
==============================================================================
--- trunk/stream/audio_in.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/audio_in.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -133,7 +133,7 @@ int audio_in_set_device(audio_in_t *ai, 
     switch (ai->type) {
 #ifdef CONFIG_ALSA
     case AUDIO_IN_ALSA:
-	if (ai->alsa.device) free(ai->alsa.device);
+	free(ai->alsa.device);
 	ai->alsa.device = strdup(device);
 	/* mplayer cannot handle colons in arguments */
 	for (i = 0; i < (int)strlen(ai->alsa.device); i++) {
@@ -143,7 +143,7 @@ int audio_in_set_device(audio_in_t *ai, 
 #endif
 #ifdef CONFIG_OSS_AUDIO
     case AUDIO_IN_OSS:
-	if (ai->oss.device) free(ai->oss.device);
+	free(ai->oss.device);
 	ai->oss.device = strdup(device);
 	return 0;
 #endif

Modified: trunk/stream/cdinfo.c
==============================================================================
--- trunk/stream/cdinfo.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/cdinfo.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -54,15 +54,15 @@ void
 cd_info_free(cd_info_t *cd_info) {
 	cd_track_t *cd_track, *cd_track_next;
 	if( cd_info==NULL ) return;
-	if( cd_info->artist!=NULL ) free(cd_info->artist);
-	if( cd_info->album!=NULL ) free(cd_info->album);
-	if( cd_info->genre!=NULL ) free(cd_info->genre);
+	free(cd_info->artist);
+	free(cd_info->album);
+	free(cd_info->genre);
 
 	cd_track_next = cd_info->first;
 	while( cd_track_next!=NULL ) {
 		cd_track = cd_track_next;
 		cd_track_next = cd_track->next;
-		if( cd_track->name!=NULL ) free(cd_track->name);
+		free(cd_track->name);
 		free(cd_track);
 	}
 }

Modified: trunk/stream/http.c
==============================================================================
--- trunk/stream/http.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/http.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -307,17 +307,16 @@ void
 http_free( HTTP_header_t *http_hdr ) {
 	HTTP_field_t *field, *field2free;
 	if( http_hdr==NULL ) return;
-	if( http_hdr->protocol!=NULL ) free( http_hdr->protocol );
-	if( http_hdr->uri!=NULL ) free( http_hdr->uri );
-	if( http_hdr->reason_phrase!=NULL ) free( http_hdr->reason_phrase );
-	if( http_hdr->field_search!=NULL ) free( http_hdr->field_search );
-	if( http_hdr->method!=NULL ) free( http_hdr->method );
-	if( http_hdr->buffer!=NULL ) free( http_hdr->buffer );
+	free(http_hdr->protocol);
+	free(http_hdr->uri);
+	free(http_hdr->reason_phrase);
+	free(http_hdr->field_search);
+	free(http_hdr->method);
+	free(http_hdr->buffer);
 	field = http_hdr->first_field;
 	while( field!=NULL ) {
 		field2free = field;
-		if (field->field_name)
-		  free(field->field_name);
+		free(field->field_name);
 		field = field->next;
 		free( field2free );
 	}
@@ -440,7 +439,7 @@ http_response_parse( HTTP_header_t *http
 		hdr_ptr = ptr+((*ptr=='\r')?2:1);
 	} while( hdr_ptr<(http_hdr->buffer+pos_hdr_sep) );
 
-	if( field!=NULL ) free( field );
+	free(field);
 
 	if( pos_hdr_sep+hdr_sep_len<http_hdr->buffer_size ) {
 		// Response has data!
@@ -513,7 +512,7 @@ http_build_request( HTTP_header_t *http_
 		memcpy( ptr, http_hdr->body, http_hdr->body_size );
 	}
 
-	if( uri ) free( uri );
+	free(uri);
 	return http_hdr->buffer;
 }
 

Modified: trunk/stream/network.c
==============================================================================
--- trunk/stream/network.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/network.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -127,9 +127,9 @@ void
 streaming_ctrl_free( streaming_ctrl_t *streaming_ctrl ) {
 	if( streaming_ctrl==NULL ) return;
 	if( streaming_ctrl->url ) url_free( streaming_ctrl->url );
-	if( streaming_ctrl->buffer ) free( streaming_ctrl->buffer );
-	if( streaming_ctrl->data ) free( streaming_ctrl->data );
-	free( streaming_ctrl );
+	free(streaming_ctrl->buffer);
+	free(streaming_ctrl->data);
+	free(streaming_ctrl);
 }
 
 URL_t*
@@ -331,14 +331,10 @@ http_authenticate(HTTP_header_t *http_hd
 		return -1;
 	}
 	if( *auth_retry>0 ) {
-		if( url->username ) {
-			free( url->username );
-			url->username = NULL;
-		}
-		if( url->password ) {
-			free( url->password );
-			url->password = NULL;
-		}
+		free(url->username);
+		url->username = NULL;
+		free(url->password);
+		url->password = NULL;
 	}
 
 	aut = http_get_field(http_hdr, "WWW-Authenticate");

Modified: trunk/stream/stream.c
==============================================================================
--- trunk/stream/stream.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -513,8 +513,8 @@ void free_stream(stream_t *s){
 #endif
   // Disabled atm, i don't like that. s->priv can be anything after all
   // streams should destroy their priv on close
-  //if(s->priv) free(s->priv);
-  if(s->url) free(s->url);
+  //free(s->priv);
+  free(s->url);
   free(s);
 }
 

Modified: trunk/stream/stream_cddb.c
==============================================================================
--- trunk/stream/stream_cddb.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream_cddb.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -792,9 +792,7 @@ static int cddb_retrieve(cddb_data_t *cd
     if (ret < 0)
         return -1;
 
-    if (cddb_data->cache_dir != NULL) {
-        free(cddb_data->cache_dir);
-    }
+    free(cddb_data->cache_dir);
     return 0;
 }
 

Modified: trunk/stream/stream_dvb.c
==============================================================================
--- trunk/stream/stream_dvb.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream_dvb.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -403,8 +403,7 @@ static dvb_channels_list *dvb_get_channe
 	fclose(f);
 	if(list->NUM_CHANNELS == 0)
 	{
-		if(list->channels != NULL)
-			free(list->channels);
+		free(list->channels);
 		free(list);
 		return NULL;
 	}
@@ -419,17 +418,13 @@ void dvb_free_config(dvb_config_t *confi
 
 	for(i=0; i<config->count; i++)
 	{
-		if(config->cards[i].name)
-			free(config->cards[i].name);
+		free(config->cards[i].name);
 		if(!config->cards[i].list)
 			continue;
 		if(config->cards[i].list->channels)
 		{
 			for(j=0; j<config->cards[i].list->NUM_CHANNELS; j++)
-			{
-				if(config->cards[i].list->channels[j].name)
-					free(config->cards[i].list->channels[j].name);
-			}
+				free(config->cards[i].list->channels[j].name);
 			free(config->cards[i].list->channels);
 		}
 		free(config->cards[i].list);
@@ -802,20 +797,17 @@ dvb_config_t *dvb_get_config(void)
 
 		if((access(conf_file, F_OK | R_OK) != 0))
 		{
-			if(conf_file)
-				free(conf_file);
+			free(conf_file);
 			conf_file = get_path("channels.conf");
 			if((access(conf_file, F_OK | R_OK) != 0))
 			{
-				if(conf_file)
-					free(conf_file);
+				free(conf_file);
 				conf_file = strdup(MPLAYER_CONFDIR "/channels.conf");
 			}
 		}
 
 		list = dvb_get_channels(conf_file, type);
-		if(conf_file)
-			free(conf_file);
+		free(conf_file);
 		if(list == NULL)
 			continue;
 

Modified: trunk/stream/stream_ftp.c
==============================================================================
--- trunk/stream/stream_ftp.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream_ftp.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -378,7 +378,7 @@ static void close_f(stream_t *s) {
   FtpSendCmd("QUIT",p,NULL);
 
   if(p->handle) closesocket(p->handle);
-  if(p->buf) free(p->buf);
+  free(p->buf);
 
   m_struct_free(&stream_opts,p);
 }

Modified: trunk/stream/stream_netstream.c
==============================================================================
--- trunk/stream/stream_netstream.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream_netstream.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -224,8 +224,7 @@ static void close_s(struct stream *s) {
   mp_net_stream_packet_t* pack;
 
   pack = send_net_stream_cmd(s,NET_STREAM_CLOSE,NULL,0);
-  if(pack)
-    free(pack);
+  free(pack);
 }
 
 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {

Modified: trunk/stream/stream_pvr.c
==============================================================================
--- trunk/stream/stream_pvr.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream_pvr.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -188,15 +188,9 @@ pvr_uninit (struct pvr_t *pvr)
   if (pvr->dev_fd)
     close (pvr->dev_fd);
 
-  if (pvr->video_dev)
-    free (pvr->video_dev);
-
-  if (pvr->stationlist.list)
-    free (pvr->stationlist.list);
-
-  if (pvr->param_channel)
-    free (pvr->param_channel);
-
+  free (pvr->video_dev);
+  free (pvr->stationlist.list);
+  free (pvr->param_channel);
   free (pvr);
 }
 
@@ -215,11 +209,8 @@ copycreate_stationlist (stationlist_t *s
 
   num = FFMAX (num, chanlists[chantab].count);
 
-  if (stationlist->list)
-  {
-    free (stationlist->list);
-    stationlist->list = NULL;
-  }
+  free (stationlist->list);
+  stationlist->list = NULL;
 
   stationlist->total = 0;
   stationlist->enabled = 0;
@@ -1151,8 +1142,7 @@ parse_v4l2_tv_options (struct pvr_t *pvr
 
   if (stream_tv_defaults.device)
   {
-    if (pvr->video_dev)
-      free (pvr->video_dev);
+    free (pvr->video_dev);
     pvr->video_dev = strdup (stream_tv_defaults.device);
   }
 

Modified: trunk/stream/stream_radio.c
==============================================================================
--- trunk/stream/stream_radio.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/stream_radio.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -1225,10 +1225,8 @@ static void close_s(struct stream *strea
     if (!priv) return;
 
 #ifdef CONFIG_RADIO_CAPTURE
-    if(priv->audio_ringbuffer){
-        free(priv->audio_ringbuffer);
-        priv->audio_ringbuffer=NULL;
-    }
+    free(priv->audio_ringbuffer);
+    priv->audio_ringbuffer = NULL;
 
     priv->do_capture=0;
 #endif

Modified: trunk/stream/tv.c
==============================================================================
--- trunk/stream/tv.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/tv.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -108,13 +108,11 @@ tvi_handle_t *tv_new_handle(int size, co
 
 void tv_free_handle(tvi_handle_t *h)
 {
-    if (h) {
-        if (h->priv)
-            free(h->priv);
-        if (h->scan)
-            free(h->scan);
-        free(h);
-    }
+    if (!h)
+        return;
+    free(h->priv);
+    free(h->scan);
+    free(h);
 }
 
 void tv_start_scan(tvi_handle_t *tvh, int start)

Modified: trunk/stream/tvi_dshow.c
==============================================================================
--- trunk/stream/tvi_dshow.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/tvi_dshow.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -748,15 +748,12 @@ static void destroy_ringbuffer(grabber_r
 
     if (rb->ringbuffer) {
 	for (i = 0; i < rb->buffersize; i++)
-	    if (rb->ringbuffer[i])
-		free(rb->ringbuffer[i]);
+	    free(rb->ringbuffer[i]);
 	free(rb->ringbuffer);
 	rb->ringbuffer = NULL;
     }
-    if (rb->dpts) {
-	free(rb->dpts);
-	rb->dpts = NULL;
-    }
+    free(rb->dpts);
+    rb->dpts = NULL;
     if (rb->pMutex) {
 	DeleteCriticalSection(rb->pMutex);
 	free(rb->pMutex);
@@ -2091,15 +2088,13 @@ static HRESULT get_available_formats_str
     }
     if (!done) {
 	for (i = 0; i < count; i++) {
-	    if (pBuf && pBuf[i])
+	    if (pBuf)
 		free(pBuf[i]);
 	    if (arpmt && arpmt[i])
 		DeleteMediaType(arpmt[i]);
 	}
-	if (pBuf)
-	    free(pBuf);
-	if (arpmt)
-	    free(arpmt);
+	free(pBuf);
+	free(arpmt);
 	if (hr != S_OK) {
 	    mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: Call to GetStreamCaps failed (get_available_formats_stream)\n");
 	    return hr;
@@ -2221,8 +2216,7 @@ static HRESULT get_available_formats_pin
 	for (i = 0; i < count; i++) {
 	    if (arpmt[i])
 		DeleteMediaType(arpmt[i]);
-	    if (pBuf[i])
-		free(pBuf[i]);
+	    free(pBuf[i]);
 	}
 	free(arpmt);
 	free(pBuf);

Modified: trunk/stream/tvi_v4l.c
==============================================================================
--- trunk/stream/tvi_v4l.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/tvi_v4l.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -676,10 +676,8 @@ static int init(priv_t *priv)
     return 1;
 
 malloc_failed:
-    if (priv->channels)
-        free(priv->channels);
-    if (priv->buf)
-        free(priv->buf);
+    free(priv->channels);
+    free(priv->buf);
 err:
     if (priv->video_fd != -1)
         close(priv->video_fd);
@@ -702,10 +700,8 @@ static int uninit(priv_t *priv)
         priv->vbi_fd=0;
     }
 
-    if(priv->vbi_dev){
-        free(priv->vbi_dev);
-        priv->vbi_dev=0;
-    }
+    free(priv->vbi_dev);
+    priv->vbi_dev = NULL;
 
     priv->shutdown = 1;
 
@@ -752,15 +748,11 @@ static int uninit(priv_t *priv)
         free(priv->video_ringbuffer);
     }
 
-    if (priv->video_timebuffer)
-        free(priv->video_timebuffer);
-    if (priv->video_avg_buffer)
-        free(priv->video_avg_buffer);
+    free(priv->video_timebuffer);
+    free(priv->video_avg_buffer);
     if (!priv->tv_param->noaudio) {
-        if (priv->audio_ringbuffer)
-            free(priv->audio_ringbuffer);
-        if (priv->audio_skew_buffer)
-            free(priv->audio_skew_buffer);
+        free(priv->audio_ringbuffer);
+        free(priv->audio_skew_buffer);
     }
 
     return 1;

Modified: trunk/stream/tvi_v4l2.c
==============================================================================
--- trunk/stream/tvi_v4l2.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/tvi_v4l2.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -1112,10 +1112,8 @@ static int uninit(priv_t *priv)
         priv->vbi_fd=0;
     }
 
-    if(priv->vbi_dev){
-        free(priv->vbi_dev);
-	priv->vbi_dev=0;
-    }
+    free(priv->vbi_dev);
+    priv->vbi_dev = NULL;
     priv->shutdown = 1;
     if(priv->video_grabber_thread)
         pthread_join(priv->video_grabber_thread, NULL);
@@ -1173,12 +1171,9 @@ static int uninit(priv_t *priv)
         free(priv->video_ringbuffer);
     }
     if (!priv->tv_param->noaudio) {
-        if (priv->audio_ringbuffer)
-            free(priv->audio_ringbuffer);
-        if (priv->audio_skew_buffer)
-            free(priv->audio_skew_buffer);
-        if (priv->audio_skew_delta_buffer)
-            free(priv->audio_skew_delta_buffer);
+        free(priv->audio_ringbuffer);
+        free(priv->audio_skew_buffer);
+        free(priv->audio_skew_delta_buffer);
 
         audio_in_uninit(&priv->audio_in);
     }

Modified: trunk/stream/url.c
==============================================================================
--- trunk/stream/url.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/stream/url.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -233,7 +233,7 @@ url_new(const char* url) {
         free(escfilename);
 	return Curl;
 err_out:
-	if (escfilename) free(escfilename);
+	free(escfilename);
 	if (Curl) url_free(Curl);
 	return NULL;
 }
@@ -241,12 +241,12 @@ err_out:
 void
 url_free(URL_t* url) {
 	if(!url) return;
-	if(url->url) free(url->url);
-	if(url->protocol) free(url->protocol);
-	if(url->hostname) free(url->hostname);
-	if(url->file) free(url->file);
-	if(url->username) free(url->username);
-	if(url->password) free(url->password);
+	free(url->url);
+	free(url->protocol);
+	free(url->hostname);
+	free(url->file);
+	free(url->username);
+	free(url->password);
 	free(url);
 }
 
@@ -379,8 +379,8 @@ url_escape_string(char *outbuf, const ch
 		i += strlen(in);
 	}
 	*outbuf = '\0';
-	if(tmp) free(tmp);
-	if(unesc) free(unesc);
+	free(tmp);
+	free(unesc);
 }
 
 #ifdef URL_DEBUG

Modified: trunk/sub/font_load.c
==============================================================================
--- trunk/sub/font_load.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/sub/font_load.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -168,8 +168,7 @@ while(fgets(sor,1020,f)){
 
   if(strcmp(section,"[fpath]")==0){
       if(pdb==1){
-	  if (desc->fpath)
-	     free (desc->fpath); // release previously allocated memory
+          free (desc->fpath); // release previously allocated memory
           desc->fpath=strdup(p[0]);
           continue;
       }
@@ -344,12 +343,9 @@ return desc;
 fail_out:
   if (f)
     fclose(f);
-  if (desc->fpath)
-    free(desc->fpath);
-  if (desc->name)
-    free(desc->name);
-  if (desc)
-    free(desc);
+  free(desc->fpath);
+  free(desc->name);
+  free(desc);
   return NULL;
 }
 

Modified: trunk/sub/font_load_ft.c
==============================================================================
--- trunk/sub/font_load_ft.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/sub/font_load_ft.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -860,27 +860,27 @@ void free_font_desc(font_desc_t *desc)
 
 //    if (!desc->dynamic) return; // some vo_aa crap, better leaking than crashing
 
-    if (desc->name) free(desc->name);
-    if (desc->fpath) free(desc->fpath);
+    free(desc->name);
+    free(desc->fpath);
 
     for(i = 0; i < 16; i++) {
 	if (desc->pic_a[i]) {
-	    if (desc->pic_a[i]->bmp) free(desc->pic_a[i]->bmp);
-	    if (desc->pic_a[i]->pal) free(desc->pic_a[i]->pal);
-	    free (desc->pic_a[i]);
+	    free(desc->pic_a[i]->bmp);
+	    free(desc->pic_a[i]->pal);
+	    free(desc->pic_a[i]);
 	}
 	if (desc->pic_b[i]) {
-	    if (desc->pic_b[i]->bmp) free(desc->pic_b[i]->bmp);
-	    if (desc->pic_b[i]->pal) free(desc->pic_b[i]->pal);
-	    free (desc->pic_b[i]);
+	    free(desc->pic_b[i]->bmp);
+	    free(desc->pic_b[i]->pal);
+	    free(desc->pic_b[i]);
 	}
     }
 
-    if (desc->tables.g) free(desc->tables.g);
-    if (desc->tables.gt2) free(desc->tables.gt2);
-    if (desc->tables.om) free(desc->tables.om);
-    if (desc->tables.omt) free(desc->tables.omt);
-    if (desc->tables.tmp) free(desc->tables.tmp);
+    free(desc->tables.g);
+    free(desc->tables.gt2);
+    free(desc->tables.om);
+    free(desc->tables.omt);
+    free(desc->tables.tmp);
 
     for(i = 0; i < desc->face_cnt; i++) {
 	FT_Done_Face(desc->faces[i]);

Modified: trunk/sub/spudec.c
==============================================================================
--- trunk/sub/spudec.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/sub/spudec.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -146,8 +146,7 @@ static packet_t *spudec_dequeue_packet(s
 
 static void spudec_free_packet(packet_t *packet)
 {
-  if (packet->packet != NULL)
-    free(packet->packet);
+  free(packet->packet);
   free(packet);
 }
 
@@ -609,8 +608,7 @@ void spudec_assemble(void *this, unsigne
     unsigned int len2 = get_be16(packet);
     // Start new fragment
     if (spu->packet_reserve < len2) {
-      if (spu->packet != NULL)
-	free(spu->packet);
+      free(spu->packet);
       spu->packet = malloc(len2);
       spu->packet_reserve = spu->packet != NULL ? len2 : 0;
     }

Modified: trunk/sub/sub_cc.c
==============================================================================
--- trunk/sub/sub_cc.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/sub/sub_cc.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -81,7 +81,10 @@ static void clear_buffer(subtitle *buf)
 {
 	int i;
 	buf->lines=0;
-	for(i=0;i<SUB_MAX_TEXT;i++) if(buf->text[i]) {free(buf->text[i]);buf->text[i]=NULL;}
+	for (i = 0; i < SUB_MAX_TEXT; i++) {
+		free(buf->text[i]);
+		buf->text[i] = NULL;
+	}
 }
 
 
@@ -95,7 +98,7 @@ static void scroll_buffer(subtitle* buf)
 
 	while(buf->lines > cc_lines)
 	{
-		if(buf->text[0]) free(buf->text[0]);
+		free(buf->text[0]);
 
 		for(i = 0; i < (buf->lines - 1); i++) buf->text[i] = buf->text[i+1];
 

Modified: trunk/sub/subreader.c
==============================================================================
--- trunk/sub/subreader.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/sub/subreader.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -1513,7 +1513,7 @@ sub_data* sub_read_file (char *filename,
 #ifdef CONFIG_ICONV
           subcp_close();
 #endif
-    	  if ( first ) free(first);
+	  free(first);
 	  free(alloced_sub);
 	  return NULL;
 	 }
@@ -2043,7 +2043,7 @@ char** sub_filenames(const char* path, c
 
     }
 
-    if (tmp_sub_id) free(tmp_sub_id);
+    free(tmp_sub_id);
 
     free(f_dir);
     free(f_fname);

Modified: trunk/sub/vobsub.c
==============================================================================
--- trunk/sub/vobsub.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/sub/vobsub.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -311,8 +311,7 @@ static mpeg_t *mpeg_open(const char *fil
 
 static void mpeg_free(mpeg_t *mpeg)
 {
-    if (mpeg->packet)
-        free(mpeg->packet);
+    free(mpeg->packet);
     if (mpeg->stream)
         rar_close(mpeg->stream);
     free(mpeg);
@@ -433,8 +432,7 @@ static int mpeg_run(mpeg_t *mpeg)
             }
             mpeg->packet_size = len - ((unsigned int) mpeg_tell(mpeg) - idx);
             if (mpeg->packet_reserve < mpeg->packet_size) {
-                if (mpeg->packet)
-                    free(mpeg->packet);
+                free(mpeg->packet);
                 mpeg->packet = malloc(mpeg->packet_size);
                 if (mpeg->packet)
                     mpeg->packet_reserve = mpeg->packet_size;
@@ -507,8 +505,7 @@ static void packet_construct(packet_t *p
 
 static void packet_destroy(packet_t *pkt)
 {
-    if (pkt->data)
-        free(pkt->data);
+    free(pkt->data);
 }
 
 static void packet_queue_construct(packet_queue_t *queue)
@@ -634,8 +631,7 @@ static int vobsub_add_id(vobsub_t *vob, 
     if (vobsub_ensure_spu_stream(vob, index) < 0)
         return -1;
     if (id && idlen) {
-        if (vob->spu_streams[index].id)
-            free(vob->spu_streams[index].id);
+        free(vob->spu_streams[index].id);
         vob->spu_streams[index].id = malloc(idlen + 1);
         if (vob->spu_streams[index].id == NULL) {
             mp_msg(MSGT_VOBSUB, MSGL_FATAL, "vobsub_add_id: malloc failure");
@@ -866,8 +862,7 @@ static int vobsub_parse_one_line(vobsub_
             mp_msg(MSGT_VOBSUB, MSGL_ERR,  "ERROR in %s", line);
         break;
     } while (1);
-    if (line)
-      free(line);
+    free(line);
     return res;
 }
 
@@ -983,8 +978,7 @@ void *vobsub_open(const char *const name
             }
             if (spu)
                 *spu = spudec_new_scaled(vob->palette, vob->orig_frame_width, vob->orig_frame_height, extradata, extradata_len);
-            if (extradata)
-                free(extradata);
+            free(extradata);
 
             /* read the indexed mpeg_stream */
             strcpy(buf, name);

Modified: trunk/subopt-helper.c
==============================================================================
--- trunk/subopt-helper.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/subopt-helper.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -226,8 +226,7 @@ int subopt_parse( char const * const str
                   tmp.str = NULL;
                   tmp.len = 0;
                   last = parse_str( &str[parse_pos], &tmp );
-                  if (*valp)
-                    free(*valp);
+                  free(*valp);
                   *valp = NULL;
                   if (tmp.str && tmp.len > 0) {
                     *valp = malloc(tmp.len + 1);

Modified: trunk/xvid_vbr.c
==============================================================================
--- trunk/xvid_vbr.c	Sun Nov  7 12:03:47 2010	(r32597)
+++ trunk/xvid_vbr.c	Sun Nov  7 13:47:40 2010	(r32598)
@@ -1580,8 +1580,7 @@ static int vbr_finish_2pass2(void *sstat
 		return(-1);
 
 	/* Free the memory */
-	if(state->keyframe_locations)
-		free(state->keyframe_locations);
+	free(state->keyframe_locations);
 
 	return(0);
 


More information about the MPlayer-cvslog mailing list