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,9 +449,7 @@ Util_BuildEOLList(char *word[])
PyList_SetItem(list, i - 1, uni_part);
}
if (last)
g_free (last);
if (accum)
g_free (accum);
return list;
@ -1465,7 +1463,6 @@ 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);
}
@ -1485,7 +1482,6 @@ Plugin_RemoveAllHooks(PyObject *plugin)
}
Py_DECREF(hook->callback);
Py_DECREF(hook->userdata);
if (hook->name)
g_free(hook->name);
g_free(hook);
list = list->next;

View File

@ -699,7 +699,7 @@ get_default_spell_languages (void)
}
}
}
if (last != NULL)
g_free (last);
if (lang_list[0])

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->proxy);
g_free (dcc->file);
if (dcc->destfile)
g_free (dcc->destfile);
free (dcc->nick);
free (dcc);
g_free (dcc);
return;
}
@ -561,9 +558,7 @@ 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);
return 1;
}
@ -571,9 +566,7 @@ dcc_chat_line (struct DCC *dcc, char *line)
/* did the plugin eat the event? */
if (ret)
{
if (utf)
g_free (utf);
if (conv)
g_free (conv);
return 0;
}
@ -591,9 +584,7 @@ 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);
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);
}
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);
}
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);

View File

@ -403,7 +403,6 @@ 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);
}

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,7 +683,6 @@ 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);
return len;
@ -916,7 +915,6 @@ PrintTextTimeStamp (session *sess, char *text, time_t timestamp)
scrollback_save (sess, text);
fe_print_text (sess, text, timestamp, FALSE);
if (conv)
g_free (conv);
}

View File

@ -1643,7 +1643,6 @@ parse_dh (char *str, DH **dh_out, unsigned char **secret_out, int *keysize_out)
return 1;
fail:
if (decoded_data)
g_free (decoded_data);
return 0;
}

View File

@ -241,9 +241,7 @@ 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);
}

View File

@ -758,11 +758,8 @@ 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);
if (have_enchant) {

View File

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