summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
authorArnavion <arnavion@gmail.com>2014-12-08 21:24:59 -0800
committerArnavion <arnavion@gmail.com>2014-12-08 21:24:59 -0800
commit65da34f19eab5edde0615ccc4a58be1947cfce6e (patch)
treed7859d3241ec8c91cca590d8ec96f38fc6a7c52e /src/common
parentb7afcc36321b9a61b208f9cd4071f60a3894c1cf (diff)
Removed some unnecessary null-checks for calls to g_free and g_strfreev
Diffstat (limited to 'src/common')
-rw-r--r--src/common/cfgfiles.c4
-rw-r--r--src/common/dcc.c73
-rw-r--r--src/common/outbound.c16
-rw-r--r--src/common/server.c3
-rw-r--r--src/common/text.c10
-rw-r--r--src/common/util.c3
6 files changed, 38 insertions, 71 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index 12b66ac4..020e3bc1 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -699,8 +699,8 @@ get_default_spell_languages (void)
 				}
 			}
 		}
-		if (last != NULL)
-			g_free(last);
+
+		g_free (last);
 
 		if (lang_list[0])
 			return g_strdup (ret);
diff --git a/src/common/dcc.c b/src/common/dcc.c
index ebb89386..39056769 100644
--- a/src/common/dcc.c
+++ b/src/common/dcc.c
@@ -416,14 +416,11 @@ dcc_close (struct DCC *dcc, int dccstat, int destroy)
 	{
 		dcc_list = g_slist_remove (dcc_list, dcc);
 		fe_dcc_remove (dcc);
-		if (dcc->proxy)
-			free (dcc->proxy);
-		if (dcc->file)
-			g_free (dcc->file);
-		if (dcc->destfile)
-			g_free (dcc->destfile);
+		g_free (dcc->proxy);
+		g_free (dcc->file);
+		g_free (dcc->destfile);
 		free (dcc->nick);
-		free (dcc);
+		g_free (dcc);
 		return;
 	}
 
@@ -561,20 +558,16 @@ dcc_chat_line (struct DCC *dcc, char *line)
 	/* did the plugin close it? */
 	if (!g_slist_find (dcc_list, dcc))
 	{
-		if (utf)
-			g_free (utf);
-		if (conv)
-			g_free (conv);
+		g_free (utf);
+		g_free (conv);
 		return 1;
 	}
 
 	/* did the plugin eat the event? */
 	if (ret)
 	{
-		if (utf)
-			g_free (utf);
-		if (conv)
-			g_free (conv);
+		g_free (utf);
+		g_free (conv);
 		return 0;
 	}
 
@@ -591,10 +584,8 @@ dcc_chat_line (struct DCC *dcc, char *line)
 	{
 		inbound_privmsg (dcc->serv, dcc->nick, "", line, FALSE, &no_tags);
 	}
-	if (utf)
-		g_free (utf);
-	if (conv)
-		g_free (conv);
+	g_free (utf);
+	g_free (conv);
 	return 0;
 }
 
@@ -1379,14 +1370,13 @@ dcc_proxy_connect (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
 	if (!dcc_did_connect (source, condition, dcc))
 		return TRUE;
 
-	dcc->proxy = malloc (sizeof (struct proxy_state));
+	dcc->proxy = g_new0 (struct proxy_state, 1);
 	if (!dcc->proxy)
 	{
 		dcc->dccstat = STAT_FAILED;
 		fe_dcc_update (dcc);
 		return TRUE;
 	}
-	memset (dcc->proxy, 0, sizeof (struct proxy_state));
 
 	switch (prefs.hex_net_proxy_type)
 	{
@@ -2091,15 +2081,8 @@ is_same_file (struct DCC *dcc, struct DCC *new_dcc)
 	}
 
 exit:
-	if (filename_fs != NULL)
-	{
-		g_free (filename_fs);
-	}
-
-	if (new_filename_fs != NULL)
-	{
-		g_free (new_filename_fs);
-	}
+	g_free (filename_fs);
+	g_free (new_filename_fs);
 
 	if (file != NULL)
 	{
@@ -2121,25 +2104,10 @@ exit:
 		g_object_unref (new_file_info);
 	}
 
-	if (file_id != NULL)
-	{
-		g_free (file_id);
-	}
-
-	if (new_file_id != NULL)
-	{
-		g_free (new_file_id);
-	}
-
-	if (filesystem_id != NULL)
-	{
-		g_free(filesystem_id);
-	}
-
-	if (new_filesystem_id != NULL)
-	{
-		g_free(new_filesystem_id);
-	}
+	g_free (file_id);
+	g_free (new_file_id);
+	g_free(filesystem_id);
+	g_free(new_filesystem_id);
 
 	return result;
 }
@@ -2289,9 +2257,12 @@ dcc_get_nick (struct session *sess, char *nick)
 static struct DCC *
 new_dcc (void)
 {
-	struct DCC *dcc = calloc (1, sizeof (struct DCC));
+	struct DCC *dcc = g_new0 (struct DCC, 1);
 	if (!dcc)
-		return 0;
+	{
+		return NULL;
+	}
+
 	dcc->sok = -1;
 	dcc->fp = -1;
 	dcc_list = g_slist_prepend (dcc_list, dcc);
diff --git a/src/common/outbound.c b/src/common/outbound.c
index 651558ce..8d32cf38 100644
--- a/src/common/outbound.c
+++ b/src/common/outbound.c
@@ -2549,7 +2549,7 @@ cmd_load (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 			PrintText (sess, errorstring (errno));
 			g_free (buf);
 		}
-		free (file);
+		g_free (file);
 		return TRUE;
 	}
 
@@ -2562,7 +2562,7 @@ cmd_load (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 
 		file = expand_homedir (word[2]);
 		error = plugin_load (sess, file, arg);
-		free (file);
+		g_free (file);
 
 		if (error)
 			PrintText (sess, error);
@@ -2674,7 +2674,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 				if (*split_text)
 					offset += strlen(split_text);
 
-				g_free(split_text);
+				g_free (split_text);
 			}
 
 			sess->server->p_action (sess->server, sess->channel, act + offset);
@@ -2780,7 +2780,7 @@ cmd_msg (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 					if (*split_text)
 						offset += strlen(split_text);
 
-					g_free(split_text);
+					g_free (split_text);
 				}
 				sess->server->p_message (sess->server, nick, msg + offset);
 				offset = 0;
@@ -2801,7 +2801,7 @@ cmd_msg (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 					if (*split_text)
 						offset += strlen(split_text);
 
-					g_free(split_text);
+					g_free (split_text);
 				}
 				inbound_chanmsg (newsess->server, NULL, newsess->channel,
 									  newsess->server->nick, msg + offset, TRUE, FALSE,
@@ -2895,7 +2895,7 @@ cmd_notice (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 			if (*split_text)
 				offset += strlen(split_text);
 			
-			g_free(split_text);
+			g_free (split_text);
 		}
 
 		sess->server->p_notice (sess->server, word[2], text + offset);
@@ -3054,7 +3054,7 @@ cmd_query (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 				if (*split_text)
 					offset += strlen(split_text);
 
-				g_free(split_text);
+				g_free (split_text);
 			}
 			sess->server->p_message (sess->server, nick, msg + offset);
 			inbound_chanmsg (nick_sess->server, nick_sess, nick_sess->channel,
@@ -4565,7 +4565,7 @@ handle_say (session *sess, char *text, int check_spch)
 			if (*split_text)
 				offset += strlen(split_text);
 			
-			g_free(split_text);
+			g_free (split_text);
 		}
 
 		inbound_chanmsg (sess->server, sess, sess->channel, sess->server->nick,
diff --git a/src/common/server.c b/src/common/server.c
index 6432a2b9..174e0d17 100644
--- a/src/common/server.c
+++ b/src/common/server.c
@@ -403,8 +403,7 @@ server_inline (server *serv, char *line, int len)
 	/* let proto-irc.c handle it */
 	serv->p_inline (serv, line, len);
 
-	if (utf_line_allocated != NULL) /* only if a special copy was allocated */
-		g_free (utf_line_allocated);
+	g_free (utf_line_allocated);
 }
 
 /* read data from socket */
diff --git a/src/common/text.c b/src/common/text.c
index 329ef37b..6a6b65e7 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -177,7 +177,7 @@ scrollback_shrink (session *sess)
 	g_free (file);
 	if (fh == -1)
 	{
-		free (buf);
+		g_free (buf);
 		return;
 	}
 
@@ -200,7 +200,7 @@ scrollback_shrink (session *sess)
 	}
 
 	close (fh);
-	free (buf);
+	g_free (buf);
 }
 
 static void
@@ -683,8 +683,7 @@ get_stamp_str (char *fmt, time_t tim, char **ret)
 			*ret = g_locale_to_utf8 (dest, len, 0, &len, 0);
 	}
 
-	if (loc)
-		g_free (loc);
+	g_free (loc);
 
 	return len;
 }
@@ -916,8 +915,7 @@ PrintTextTimeStamp (session *sess, char *text, time_t timestamp)
 	scrollback_save (sess, text);
 	fe_print_text (sess, text, timestamp, FALSE);
 
-	if (conv)
-		g_free (conv);
+	g_free (conv);
 }
 
 void
diff --git a/src/common/util.c b/src/common/util.c
index bfcc28a9..dd189f3d 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1643,8 +1643,7 @@ parse_dh (char *str, DH **dh_out, unsigned char **secret_out, int *keysize_out)
 	return 1;
 
 fail:
-	if (decoded_data)
-		g_free (decoded_data);
+	g_free (decoded_data);
 	return 0;
 }