1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-25 02:32:27 -05:00

Removed some unnecessary null-checks for calls to g_free and g_strfreev

This commit is contained in:
Arnavion 2014-12-08 21:24:59 -08:00
parent b7afcc3632
commit 65da34f19e
10 changed files with 48 additions and 91 deletions

View File

@ -449,10 +449,8 @@ Util_BuildEOLList(char *word[])
PyList_SetItem(list, i - 1, uni_part);
}
if (last)
g_free (last);
if (accum)
g_free (accum);
g_free (last);
g_free (accum);
return list;
}
@ -1465,8 +1463,7 @@ Plugin_RemoveHook(PyObject *plugin, Hook *hook)
hook));
Py_DECREF(hook->callback);
Py_DECREF(hook->userdata);
if (hook->name)
g_free(hook->name);
g_free(hook->name);
g_free(hook);
}
}
@ -1485,8 +1482,7 @@ Plugin_RemoveAllHooks(PyObject *plugin)
}
Py_DECREF(hook->callback);
Py_DECREF(hook->userdata);
if (hook->name)
g_free(hook->name);
g_free(hook->name);
g_free(hook);
list = list->next;
}

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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 */

View File

@ -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

View File

@ -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;
}

View File

@ -241,10 +241,8 @@ key_free (gpointer data)
g_return_if_fail (kb != NULL);
if (kb->data1)
g_free (kb->data1);
if (kb->data2)
g_free (kb->data2);
g_free (kb->data1);
g_free (kb->data2);
g_free (kb);
}

View File

@ -758,12 +758,9 @@ sexy_spell_entry_finalize(GObject *obj)
pango_attr_list_unref(entry->priv->attr_list);
if (entry->priv->dict_hash)
g_hash_table_destroy(entry->priv->dict_hash);
if (entry->priv->words)
g_strfreev(entry->priv->words);
if (entry->priv->word_starts)
g_free(entry->priv->word_starts);
if (entry->priv->word_ends)
g_free(entry->priv->word_ends);
g_strfreev(entry->priv->words);
g_free(entry->priv->word_starts);
g_free(entry->priv->word_ends);
if (have_enchant) {
if (entry->priv->broker) {

View File

@ -530,8 +530,7 @@ fe_args (int argc, char *argv[])
if (arg_cfgdir) /* we want filesystem encoding */
{
if (xdir)
g_free (xdir);
g_free (xdir);
xdir = strdup (arg_cfgdir);
if (xdir[strlen (xdir) - 1] == '/')
xdir[strlen (xdir) - 1] = 0;