summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authordiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-11-07 12:47:40 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-08 18:05:12 +0200
commit12d3e0df9980822282f70dffad148b729dbee541 (patch)
treed298b2c8f5039eae7aeeb16dfd927bea0efcc134 /stream
parentaf4b23cd36cff0dc34cde59c6a154fd080d11216 (diff)
downloadmpv-12d3e0df9980822282f70dffad148b729dbee541.tar.bz2
mpv-12d3e0df9980822282f70dffad148b729dbee541.tar.xz
cleanup: don't check for NULL before free()
patch by Clément Bœsch, ubitux gmail com git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32598 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r--stream/asf_streaming.c6
-rw-r--r--stream/audio_in.c4
-rw-r--r--stream/cdinfo.c8
-rw-r--r--stream/http.c19
-rw-r--r--stream/network.c18
-rw-r--r--stream/stream.c4
-rw-r--r--stream/stream_cddb.c4
-rw-r--r--stream/stream_dvb.c20
-rw-r--r--stream/stream_ftp.c2
-rw-r--r--stream/stream_netstream.c3
-rw-r--r--stream/stream_pvr.c22
-rw-r--r--stream/stream_radio.c6
-rw-r--r--stream/tv.c12
-rw-r--r--stream/tvi_dshow.c20
-rw-r--r--stream/tvi_v4l.c24
-rw-r--r--stream/tvi_v4l2.c15
-rw-r--r--stream/url.c18
17 files changed, 78 insertions, 127 deletions
diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c
index c50d373cab..891f519d28 100644
--- a/stream/asf_streaming.c
+++ b/stream/asf_streaming.c
@@ -401,9 +401,9 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
len_err_out:
mp_tmsg(MSGT_NETWORK, MSGL_FATAL, "Invalid length in ASF header!\n");
- 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;
}
diff --git a/stream/audio_in.c b/stream/audio_in.c
index 67a345b907..b7d388d89d 100644
--- a/stream/audio_in.c
+++ b/stream/audio_in.c
@@ -132,7 +132,7 @@ int audio_in_set_device(audio_in_t *ai, char *device)
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++) {
@@ -142,7 +142,7 @@ int audio_in_set_device(audio_in_t *ai, char *device)
#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
diff --git a/stream/cdinfo.c b/stream/cdinfo.c
index cc42bf11e4..3ec5560a24 100644
--- a/stream/cdinfo.c
+++ b/stream/cdinfo.c
@@ -53,15 +53,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);
}
}
diff --git a/stream/http.c b/stream/http.c
index 0c8bb33f56..e6b0909996 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -309,17 +309,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 );
}
@@ -442,7 +441,7 @@ http_response_parse( HTTP_header_t *http_hdr ) {
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!
@@ -515,7 +514,7 @@ http_build_request( HTTP_header_t *http_hdr ) {
memcpy( ptr, http_hdr->body, http_hdr->body_size );
}
- if( uri ) free( uri );
+ free(uri);
return http_hdr->buffer;
}
diff --git a/stream/network.c b/stream/network.c
index cbf643a6f2..d614774a96 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -128,9 +128,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*
@@ -338,14 +338,10 @@ http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry) {
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");
diff --git a/stream/stream.c b/stream/stream.c
index 041b3a8c67..6f35252e3d 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -512,8 +512,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);
}
diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c
index abc6a86966..5a4b3c1cee 100644
--- a/stream/stream_cddb.c
+++ b/stream/stream_cddb.c
@@ -783,9 +783,7 @@ static int cddb_retrieve(cddb_data_t *cddb_data)
if (ret < 0)
return -1;
- if (cddb_data->cache_dir != NULL) {
- free(cddb_data->cache_dir);
- }
+ free(cddb_data->cache_dir);
return 0;
}
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index ed8c1b81ec..13f32c29a8 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -402,8 +402,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type)
fclose(f);
if(list->NUM_CHANNELS == 0)
{
- if(list->channels != NULL)
- free(list->channels);
+ free(list->channels);
free(list);
return NULL;
}
@@ -418,17 +417,13 @@ void dvb_free_config(dvb_config_t *config)
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);
@@ -801,20 +796,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;
diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c
index 69dc326641..00027d5205 100644
--- a/stream/stream_ftp.c
+++ b/stream/stream_ftp.c
@@ -377,7 +377,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);
}
diff --git a/stream/stream_netstream.c b/stream/stream_netstream.c
index ba1bb01ee7..6240aa7044 100644
--- a/stream/stream_netstream.c
+++ b/stream/stream_netstream.c
@@ -223,8 +223,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) {
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index 3271ce9742..4048168990 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -187,15 +187,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);
}
@@ -214,11 +208,8 @@ copycreate_stationlist (stationlist_t *stationlist, int num)
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;
@@ -1150,8 +1141,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);
}
diff --git a/stream/stream_radio.c b/stream/stream_radio.c
index bfa0f18d0b..f7612f0085 100644
--- a/stream/stream_radio.c
+++ b/stream/stream_radio.c
@@ -1224,10 +1224,8 @@ static void close_s(struct stream *stream){
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
diff --git a/stream/tv.c b/stream/tv.c
index daa6b7dd7f..925109e778 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -107,13 +107,11 @@ tvi_handle_t *tv_new_handle(int size, const tvi_functions_t *functions)
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)
diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c
index 9394176719..3b4535ac8c 100644
--- a/stream/tvi_dshow.c
+++ b/stream/tvi_dshow.c
@@ -747,15 +747,12 @@ static void destroy_ringbuffer(grabber_ringbuffer_t * rb)
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);
@@ -2090,15 +2087,13 @@ static HRESULT get_available_formats_stream(chain_t *chain)
}
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;
@@ -2220,8 +2215,7 @@ static HRESULT get_available_formats_pin(ICaptureGraphBuilder2 * pBuilder,
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);
diff --git a/stream/tvi_v4l.c b/stream/tvi_v4l.c
index d380a3684e..bbf290eeaf 100644
--- a/stream/tvi_v4l.c
+++ b/stream/tvi_v4l.c
@@ -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;
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index f5cc9d0897..90cb1a6567 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -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);
}
diff --git a/stream/url.c b/stream/url.c
index 8d0176e45f..3a2d9b96e9 100644
--- a/stream/url.c
+++ b/stream/url.c
@@ -232,7 +232,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;
}
@@ -240,12 +240,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);
}
@@ -378,8 +378,8 @@ url_escape_string(char *outbuf, const char *inbuf) {
i += strlen(in);
}
*outbuf = '\0';
- if(tmp) free(tmp);
- if(unesc) free(unesc);
+ free(tmp);
+ free(unesc);
}
#ifdef URL_DEBUG