Mercurial > mplayer.hg
changeset 32511:b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
patch by From: Clment Bsch, ubitux gmail com
author | diego |
---|---|
date | Sun, 07 Nov 2010 12:47:40 +0000 |
parents | b756312f1d15 |
children | 024358659ebd |
files | 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/network.c stream/stream.c stream/stream_cddb.c stream/stream_dvb.c stream/stream_ftp.c stream/stream_netstream.c stream/stream_pvr.c stream/stream_radio.c stream/tv.c stream/tvi_dshow.c stream/tvi_v4l.c stream/tvi_v4l2.c stream/url.c sub/font_load.c sub/font_load_ft.c sub/spudec.c sub/sub_cc.c sub/subreader.c sub/vobsub.c subopt-helper.c xvid_vbr.c |
diffstat | 33 files changed, 151 insertions(+), 230 deletions(-) [+] |
line wrap: on
line diff
--- a/asxparser.c Sun Nov 07 11:03:47 2010 +0000 +++ b/asxparser.c Sun Nov 07 12:47:40 2010 +0000 @@ -87,7 +87,7 @@ 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 @@ 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 @@ 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 @@ } play_tree_set_param(pt,name,val); free(name); - if(val) free(val); + free(val); } static void @@ -498,7 +498,7 @@ 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_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 @@ } } else mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element); - if(body) free(body); + free(body); asx_free_attribs(attribs); }
--- a/codec-cfg.c Sun Nov 07 11:03:47 2010 +0000 +++ b/codec-cfg.c Sun Nov 07 12:47:40 2010 +0000 @@ -781,19 +781,13 @@ 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) {
--- a/command.c Sun Nov 07 11:03:47 2010 +0000 +++ b/command.c Sun Nov 07 12:47:40 2010 +0000 @@ -512,8 +512,7 @@ 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 @@ 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; }
--- a/m_config.c Sun Nov 07 11:03:47 2010 +0000 +++ b/m_config.c Sun Nov 07 12:47:40 2010 +0000 @@ -208,10 +208,10 @@ 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 @@ 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 @@ 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; }
--- a/m_option.c Sun Nov 07 11:03:47 2010 +0000 +++ b/m_option.c Sun Nov 07 12:47:40 2010 +0000 @@ -400,8 +400,7 @@ } if(dst) { - if(VAL(dst)) - free(VAL(dst)); + free(VAL(dst)); VAL(dst) = strdup(param); } @@ -416,7 +415,7 @@ 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 @@ free(del); if(s == 0) { - if(lst) free(lst); + free(lst); VAL(dst) = NULL; return 1; } @@ -544,7 +543,7 @@ } d[s] = NULL; - if(lst) free(lst); + free(lst); VAL(dst) = d; return 1; @@ -737,7 +736,7 @@ while(s) { n = s->next; free(s->name); - if(s->param) free(s->param); + free(s->param); free(s); s = n; }
--- a/mplayer.c Sun Nov 07 11:03:47 2010 +0000 +++ b/mplayer.c Sun Nov 07 12:47:40 2010 +0000 @@ -599,7 +599,7 @@ 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 @@ 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 @@ 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 @@ 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();
--- a/playtree.c Sun Nov 07 11:03:47 2010 +0000 +++ b/playtree.c Sun Nov 07 12:47:40 2010 +0000 @@ -68,7 +68,7 @@ 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 @@ 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));
--- a/playtreeparser.c Sun Nov 07 11:03:47 2010 +0000 +++ b/playtreeparser.c Sun Nov 07 12:47:40 2010 +0000 @@ -355,14 +355,9 @@ 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 @@ 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 @@ } } 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 @@ assert(p != NULL); #endif - if(p->buffer) free(p->buffer); - if(p->line) free(p->line); + free(p->buffer); + free(p->line); free(p); }
--- a/stream/asf_streaming.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/asf_streaming.c Sun Nov 07 12:47:40 2010 +0000 @@ -400,9 +400,9 @@ 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; }
--- a/stream/audio_in.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/audio_in.c Sun Nov 07 12:47:40 2010 +0000 @@ -133,7 +133,7 @@ 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 @@ #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
--- a/stream/cdinfo.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/cdinfo.c Sun Nov 07 12:47:40 2010 +0000 @@ -54,15 +54,15 @@ 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); } }
--- a/stream/http.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/http.c Sun Nov 07 12:47:40 2010 +0000 @@ -307,17 +307,16 @@ 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 @@ 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 @@ memcpy( ptr, http_hdr->body, http_hdr->body_size ); } - if( uri ) free( uri ); + free(uri); return http_hdr->buffer; }
--- a/stream/network.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/network.c Sun Nov 07 12:47:40 2010 +0000 @@ -127,9 +127,9 @@ 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 @@ 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");
--- a/stream/stream.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream.c Sun Nov 07 12:47:40 2010 +0000 @@ -513,8 +513,8 @@ #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); }
--- a/stream/stream_cddb.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream_cddb.c Sun Nov 07 12:47:40 2010 +0000 @@ -792,9 +792,7 @@ if (ret < 0) return -1; - if (cddb_data->cache_dir != NULL) { - free(cddb_data->cache_dir); - } + free(cddb_data->cache_dir); return 0; }
--- a/stream/stream_dvb.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream_dvb.c Sun Nov 07 12:47:40 2010 +0000 @@ -403,8 +403,7 @@ 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 @@ 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 @@ 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;
--- a/stream/stream_ftp.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream_ftp.c Sun Nov 07 12:47:40 2010 +0000 @@ -378,7 +378,7 @@ 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); }
--- a/stream/stream_netstream.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream_netstream.c Sun Nov 07 12:47:40 2010 +0000 @@ -224,8 +224,7 @@ 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) {
--- a/stream/stream_pvr.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream_pvr.c Sun Nov 07 12:47:40 2010 +0000 @@ -188,15 +188,9 @@ 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 @@ 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 @@ 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); }
--- a/stream/stream_radio.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/stream_radio.c Sun Nov 07 12:47:40 2010 +0000 @@ -1225,10 +1225,8 @@ 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
--- a/stream/tv.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/tv.c Sun Nov 07 12:47:40 2010 +0000 @@ -108,13 +108,11 @@ 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)
--- a/stream/tvi_dshow.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/tvi_dshow.c Sun Nov 07 12:47:40 2010 +0000 @@ -748,15 +748,12 @@ 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 @@ } 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 @@ 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);
--- a/stream/tvi_v4l.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/tvi_v4l.c Sun Nov 07 12:47:40 2010 +0000 @@ -676,10 +676,8 @@ 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 @@ 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 @@ 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;
--- a/stream/tvi_v4l2.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/tvi_v4l2.c Sun Nov 07 12:47:40 2010 +0000 @@ -1112,10 +1112,8 @@ 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 @@ 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); }
--- a/stream/url.c Sun Nov 07 11:03:47 2010 +0000 +++ b/stream/url.c Sun Nov 07 12:47:40 2010 +0000 @@ -233,7 +233,7 @@ free(escfilename); return Curl; err_out: - if (escfilename) free(escfilename); + free(escfilename); if (Curl) url_free(Curl); return NULL; } @@ -241,12 +241,12 @@ 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 @@ i += strlen(in); } *outbuf = '\0'; - if(tmp) free(tmp); - if(unesc) free(unesc); + free(tmp); + free(unesc); } #ifdef URL_DEBUG
--- a/sub/font_load.c Sun Nov 07 11:03:47 2010 +0000 +++ b/sub/font_load.c Sun Nov 07 12:47:40 2010 +0000 @@ -168,8 +168,7 @@ 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 @@ 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; }
--- a/sub/font_load_ft.c Sun Nov 07 11:03:47 2010 +0000 +++ b/sub/font_load_ft.c Sun Nov 07 12:47:40 2010 +0000 @@ -860,27 +860,27 @@ // 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]);
--- a/sub/spudec.c Sun Nov 07 11:03:47 2010 +0000 +++ b/sub/spudec.c Sun Nov 07 12:47:40 2010 +0000 @@ -146,8 +146,7 @@ static void spudec_free_packet(packet_t *packet) { - if (packet->packet != NULL) - free(packet->packet); + free(packet->packet); free(packet); } @@ -609,8 +608,7 @@ 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; }
--- a/sub/sub_cc.c Sun Nov 07 11:03:47 2010 +0000 +++ b/sub/sub_cc.c Sun Nov 07 12:47:40 2010 +0000 @@ -81,7 +81,10 @@ { 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 @@ 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];
--- a/sub/subreader.c Sun Nov 07 11:03:47 2010 +0000 +++ b/sub/subreader.c Sun Nov 07 12:47:40 2010 +0000 @@ -1513,7 +1513,7 @@ #ifdef CONFIG_ICONV subcp_close(); #endif - if ( first ) free(first); + free(first); free(alloced_sub); return NULL; } @@ -2043,7 +2043,7 @@ } - if (tmp_sub_id) free(tmp_sub_id); + free(tmp_sub_id); free(f_dir); free(f_fname);
--- a/sub/vobsub.c Sun Nov 07 11:03:47 2010 +0000 +++ b/sub/vobsub.c Sun Nov 07 12:47:40 2010 +0000 @@ -311,8 +311,7 @@ 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 @@ } 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_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 @@ 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 @@ 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 @@ } 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);
--- a/subopt-helper.c Sun Nov 07 11:03:47 2010 +0000 +++ b/subopt-helper.c Sun Nov 07 12:47:40 2010 +0000 @@ -226,8 +226,7 @@ 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);