From: <the...@us...> - 2006-08-05 08:27:51
|
Revision: 16638 Author: thekingant Date: 2006-08-05 01:27:39 -0700 (Sat, 05 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16638&view=rev Log Message: ----------- A bunch of small changes. Mostly remove "if not null" checks before calling g_free, g_list_free, g_slist_free and g_strdup. Also use g_list_foreach() to call g_free to free strings in an array. And some whitespace changes here and there. Modified Paths: -------------- trunk/plugins/codeinline.c trunk/plugins/contact_priority.c trunk/plugins/dbus-example.c trunk/plugins/history.c trunk/plugins/log_reader.c trunk/plugins/timestamp.c trunk/src/account.c trunk/src/accountopt.c trunk/src/blist.c trunk/src/buddyicon.c trunk/src/cipher.c trunk/src/cmds.c trunk/src/connection.c trunk/src/conversation.c trunk/src/core.c trunk/src/dbus-define-api.h trunk/src/dbus-server.h trunk/src/dbus-useful.c trunk/src/dbus-useful.h trunk/src/ft.c trunk/src/gaim-client-example.c trunk/src/gaim-client.c trunk/src/gtkaccount.c trunk/src/gtkblist.c trunk/src/gtkconv.c trunk/src/gtkdebug.c trunk/src/gtkft.c trunk/src/gtkimhtml.c trunk/src/gtkimhtmltoolbar.c trunk/src/gtklog.c trunk/src/gtkpluginpref.c trunk/src/gtkpounce.c trunk/src/gtkprefs.c trunk/src/gtkprivacy.c trunk/src/gtkrequest.c trunk/src/gtkroomlist.c trunk/src/gtksound.c trunk/src/gtkstatusbox.c trunk/src/gtkthemes.c trunk/src/gtkutils.c trunk/src/imgstore.c trunk/src/log.c trunk/src/notify.c trunk/src/plugin.c trunk/src/pluginpref.c trunk/src/pounce.c trunk/src/prefs.c trunk/src/protocols/oscar/oscar.c trunk/src/protocols/qq/qq.c trunk/src/proxy.c trunk/src/prpl.c trunk/src/request.c trunk/src/roomlist.c trunk/src/server.c trunk/src/signals.c trunk/src/socket.c trunk/src/status.c trunk/src/util.c trunk/src/value.c trunk/src/whiteboard.c trunk/src/xmlnode.c Property Changed: ---------------- trunk/plugins/codeinline.c Modified: trunk/plugins/codeinline.c =================================================================== --- trunk/plugins/codeinline.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/plugins/codeinline.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -48,12 +48,12 @@ static gboolean plugin_load(GaimPlugin *plugin) -{ +{ void *handle = gaim_conversations_get_handle(); plugin_handle = plugin; - gaim_signal_connect(handle, "writing-im-msg", plugin, + gaim_signal_connect(handle, "writing-im-msg", plugin, GAIM_CALLBACK(outgoing_msg_cb), NULL); - + return TRUE; } Property changes on: trunk/plugins/codeinline.c ___________________________________________________________________ Name: svn:executable - * Modified: trunk/plugins/contact_priority.c =================================================================== --- trunk/plugins/contact_priority.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/plugins/contact_priority.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -99,12 +99,12 @@ hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - + label = gtk_label_new_with_mnemonic(_(statuses[i].description)); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_size_group_add_widget(sg, label); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); - + adj = gtk_adjustment_new(gaim_prefs_get_int(pref), -500, 500, 1, 1, 1); spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0); g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(pref_update), pref); Modified: trunk/plugins/dbus-example.c =================================================================== --- trunk/plugins/dbus-example.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/plugins/dbus-example.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -51,7 +51,7 @@ #include "dbus-bindings.h" typedef struct { - char *text; + char *text; } GaimText; /* This makes the structure GaimText visible to the gaim-dbus type @@ -59,7 +59,7 @@ on, we will be able to register pointers to structures of this type. You to dbus-define types you want to be directly accessible by external applications. */ -GAIM_DBUS_DEFINE_TYPE(GaimText) +GAIM_DBUS_DEFINE_TYPE(GaimText) /* Here we make four functions accessible to other applications by DBus. These functions can access types defined in gaim proper @@ -78,30 +78,30 @@ static GaimText hello; /* Here come the definitions of the four exported functions. */ -GaimText* dbus_example_get_hello_object(void) +GaimText* dbus_example_get_hello_object(void) { - return &hello; + return &hello; } -void dbus_example_set_text(GaimText *obj, const char *text) +void dbus_example_set_text(GaimText *obj, const char *text) { - if (obj != NULL) { - g_free(obj->text); - obj->text = g_strdup(text); - } + if (obj != NULL) { + g_free(obj->text); + obj->text = g_strdup(text); + } } -const char *dbus_example_get_text(GaimText *obj) +const char *dbus_example_get_text(GaimText *obj) { - if (obj != NULL) - return obj->text; - else - return NULL; + if (obj != NULL) + return obj->text; + else + return NULL; } -const char *dbus_example_get_buddy_name(GaimBuddy *buddy) +const char *dbus_example_get_buddy_name(GaimBuddy *buddy) { - return gaim_buddy_get_name(buddy); + return gaim_buddy_get_name(buddy); } /* And now standard plugin stuff */ @@ -111,33 +111,33 @@ { GAIM_DBUS_RETURN_FALSE_IF_DISABLED(plugin); - /* First, we have to register our four exported functions with the - main gaim dbus loop. Without this statement, the gaim dbus - code wouldn't know about our functions. */ - GAIM_DBUS_REGISTER_BINDINGS(plugin); + /* First, we have to register our four exported functions with the + main gaim dbus loop. Without this statement, the gaim dbus + code wouldn't know about our functions. */ + GAIM_DBUS_REGISTER_BINDINGS(plugin); - /* Then, we register the hello object of type GaimText. Note that - pointer registrations / unregistrations are completely dynamic; - they don't have to be made when the plugin is loaded / - unloaded. Without this statement the dbus gaim code wouldn't - know about the hello object. */ - GAIM_DBUS_REGISTER_POINTER(&hello, GaimText); + /* Then, we register the hello object of type GaimText. Note that + pointer registrations / unregistrations are completely dynamic; + they don't have to be made when the plugin is loaded / + unloaded. Without this statement the dbus gaim code wouldn't + know about the hello object. */ + GAIM_DBUS_REGISTER_POINTER(&hello, GaimText); - hello.text = g_strdup("Hello."); - - return TRUE; + hello.text = g_strdup("Hello."); + + return TRUE; } static gboolean plugin_unload(GaimPlugin *plugin) { - g_free(hello.text); + g_free(hello.text); - /* It is necessary to unregister all pointers registered by the module. */ - GAIM_DBUS_UNREGISTER_POINTER(&hello); + /* It is necessary to unregister all pointers registered by the module. */ + GAIM_DBUS_UNREGISTER_POINTER(&hello); - return TRUE; + return TRUE; } static GaimPluginInfo info = Modified: trunk/plugins/history.c =================================================================== --- trunk/plugins/history.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/plugins/history.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -90,7 +90,7 @@ if (logs == NULL) logs = gaim_log_get_logs(GAIM_LOG_IM, name, account); else - logs = g_list_sort(logs, gaim_log_compare); + logs = g_list_sort(logs, gaim_log_compare); } else if (convtype == GAIM_CONV_TYPE_CHAT) { Modified: trunk/plugins/log_reader.c =================================================================== --- trunk/plugins/log_reader.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/plugins/log_reader.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -300,7 +300,7 @@ if (!data->path || stat(data->path, &st)) st.st_size = 0; - + return st.st_size; } @@ -399,7 +399,7 @@ g_return_val_if_fail(log != NULL, g_strdup("")); data = log->logger_data; - + /* TODO: Do something here. */ return g_strdup(""); } Modified: trunk/plugins/timestamp.c =================================================================== --- trunk/plugins/timestamp.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/plugins/timestamp.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -120,7 +120,7 @@ gaim_conversation_set_data(conv, "timestamp-initialized", GINT_TO_POINTER(TRUE)); gaim_conversation_set_data(conv, "timestamp-enabled", GINT_TO_POINTER(TRUE)); gaim_conversation_set_data(conv, "timestamp-conv-active", GINT_TO_POINTER(TRUE)); - gtk_text_buffer_create_tag (buffer, "TIMESTAMP", "foreground", "#888888", "justification", GTK_JUSTIFY_CENTER, + gtk_text_buffer_create_tag (buffer, "TIMESTAMP", "foreground", "#888888", "justification", GTK_JUSTIFY_CENTER, "weight", PANGO_WEIGHT_BOLD, NULL); do_timestamp(conv); } Modified: trunk/src/account.c =================================================================== --- trunk/src/account.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/account.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -792,8 +792,7 @@ { GaimAccountSetting *setting = (GaimAccountSetting *)data; - if (setting->ui != NULL) - g_free(setting->ui); + g_free(setting->ui); if (setting->type == GAIM_PREF_STRING) g_free(setting->value.string); @@ -1178,7 +1177,7 @@ g_return_if_fail(account != NULL); g_free(account->username); - account->username = (username == NULL ? NULL : g_strdup(username)); + account->username = g_strdup(username); schedule_accounts_save(); } @@ -1189,8 +1188,7 @@ g_return_if_fail(account != NULL); g_free(account->password); - account->password = NULL; - account->password = (password == NULL ? NULL : g_strdup(password)); + account->password = g_strdup(password); schedule_accounts_save(); } @@ -1212,7 +1210,7 @@ { char *old = account->alias; - account->alias = (alias == NULL ? NULL : g_strdup(alias)); + account->alias = g_strdup(alias); gaim_signal_emit(gaim_accounts_get_handle(), "account-alias-changed", account, old); g_free(old); @@ -1227,7 +1225,7 @@ g_return_if_fail(account != NULL); g_free(account->user_info); - account->user_info = (user_info == NULL ? NULL : g_strdup(user_info)); + account->user_info = g_strdup(user_info); schedule_accounts_save(); } @@ -1263,7 +1261,7 @@ } g_free(account->buddy_icon); - account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); + account->buddy_icon = g_strdup(icon); if (gaim_account_is_connected(account)) { char *filename = gaim_buddy_icons_get_full_path(icon); @@ -1362,11 +1360,7 @@ /* Old with the old... */ if (account->status_types != NULL) { - GList *l; - - for (l = account->status_types; l != NULL; l = l->next) - gaim_status_type_destroy((GaimStatusType *)l->data); - + g_list_foreach(account->status_types, (GFunc)gaim_status_type_destroy, NULL); g_list_free(account->status_types); } Modified: trunk/src/accountopt.c =================================================================== --- trunk/src/accountopt.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/accountopt.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -87,8 +87,7 @@ if (option == NULL) return NULL; - if (default_value != NULL) - option->default_value.string = g_strdup(default_value); + option->default_value.string = g_strdup(default_value); return option; } @@ -159,10 +158,8 @@ g_return_if_fail(option != NULL); g_return_if_fail(option->type == GAIM_PREF_STRING); - if (option->default_value.string != NULL) - g_free(option->default_value.string); - - option->default_value.string = (value == NULL ? NULL : g_strdup(value)); + g_free(option->default_value.string); + option->default_value.string = g_strdup(value); } void @@ -310,8 +307,7 @@ split->text = g_strdup(text); split->field_sep = sep; - split->default_value = (default_value == NULL - ? NULL : g_strdup(default_value)); + split->default_value = g_strdup(default_value); return split; } @@ -321,12 +317,8 @@ { g_return_if_fail(split != NULL); - if (split->text != NULL) - g_free(split->text); - - if (split->default_value != NULL) - g_free(split->default_value); - + g_free(split->text); + g_free(split->default_value); g_free(split); } Modified: trunk/src/blist.c =================================================================== --- trunk/src/blist.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/blist.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -627,21 +627,21 @@ if (!gaim_account_is_connected(buddy->account)) continue; - if (new_priority == NULL) - new_priority = buddy; - else - { - int cmp; + if (new_priority == NULL) + new_priority = buddy; + else + { + int cmp; cmp = gaim_presence_compare(gaim_buddy_get_presence(new_priority), gaim_buddy_get_presence(buddy)); - if (cmp > 0 || (cmp == 0 && + if (cmp > 0 || (cmp == 0 && gaim_prefs_get_bool("/core/contact/last_match"))) - { - new_priority = buddy; - } - } + { + new_priority = buddy; + } + } } contact->priority = new_priority; @@ -1055,7 +1055,7 @@ /* Make a list of what the groups each buddy is in */ for(cur = buddies; cur; cur = cur->next) { GaimBlistNode *node = (GaimBlistNode *)cur->data; - groups = g_list_append(groups, node->parent->parent); + groups = g_list_prepend(groups, node->parent->parent); } gaim_account_remove_buddies(account, buddies, groups); @@ -2037,7 +2037,7 @@ const char *gaim_chat_get_name(GaimChat *chat) { struct proto_chat_entry *pce; - GList *parts, *tmp; + GList *parts; char *ret; g_return_val_if_fail(chat != NULL, NULL); @@ -2048,8 +2048,7 @@ parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); pce = parts->data; ret = g_hash_table_lookup(chat->components, pce->identifier); - for (tmp = parts; tmp; tmp = tmp->next) - g_free(tmp->data); + g_list_foreach(parts, (GFunc)g_free, NULL); g_list_free(parts); return ret; Modified: trunk/src/buddyicon.c =================================================================== --- trunk/src/buddyicon.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/buddyicon.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -312,7 +312,6 @@ g_return_if_fail(username != NULL); g_free(icon->username); - icon->username = g_strdup(username); } @@ -480,7 +479,6 @@ g_return_if_fail(dir != NULL); g_free(cache_dir); - cache_dir = g_strdup(dir); } Modified: trunk/src/cipher.c =================================================================== --- trunk/src/cipher.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/cipher.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -10,7 +10,7 @@ * * Original md4 taken from linux kernel * MD4 Message Digest Algorithm (RFC1320). - * + * * Implementation derived from Andrew Tridgell and Steve French's * CIFS MD4 implementation, and the cryptoapi implementation * originally based on the public domain implementation written @@ -26,16 +26,16 @@ * * des.c - DES and Triple-DES encryption/decryption Algorithm * Copyright (C) 1998 Free Software Foundation, Inc. - * + * * Please see below for more legal information! - * + * * According to the definition of DES in FIPS PUB 46-2 from December 1993. * For a description of triple encryption, see: * Bruce Schneier: Applied Cryptography. Second Edition. * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff. - * + * * This file is part of GnuPG. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or Modified: trunk/src/cmds.c =================================================================== --- trunk/src/cmds.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/cmds.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -71,9 +71,9 @@ c->args = g_strdup(args); c->priority = p; c->flags = f; - c->prpl_id = prpl_id ? g_strdup(prpl_id) : NULL; + c->prpl_id = g_strdup(prpl_id); c->func = func; - c->help = helpstr ? g_strdup(helpstr) : NULL; + c->help = g_strdup(helpstr); c->data = data; cmds = g_list_insert_sorted(cmds, c, (GCompareFunc)cmds_compare_func); @@ -85,11 +85,8 @@ { g_free(c->cmd); g_free(c->args); - if (c->prpl_id) - g_free(c->prpl_id); - if (c->help) - g_free(c->help); - + g_free(c->prpl_id); + g_free(c->help); g_free(c); } @@ -109,6 +106,10 @@ } } +/** + * This sets args to a NULL-terminated array of strings. It should + * be freed using g_strfreev(). + */ static gboolean gaim_cmd_parse_args(GaimCmd *cmd, const gchar *s, const gchar *m, gchar ***args) { int i; @@ -142,7 +143,7 @@ (*args)[i] = gaim_markup_slice(m, g_utf8_pointer_to_offset(s, cur), g_utf8_pointer_to_offset(s, end)); cur = end +1; } - break; + break; case 's': (*args)[i] = g_strdup(cur); cur = cur + strlen(cur); @@ -160,15 +161,6 @@ return TRUE; } -static void gaim_cmd_free_args(gchar **args) -{ - int i; - - for (i = 0; args[i]; i++) - g_free(args[i]); - g_free(args); -} - static void gaim_cmd_strip_current_char(gunichar c, char *s, guint len) { int bytes; @@ -260,7 +252,7 @@ /* this checks the allow bad args flag for us */ if (!gaim_cmd_parse_args(c, rest, mrest, &args)) { - gaim_cmd_free_args(args); + g_strfreev(args); args = NULL; continue; } @@ -268,10 +260,9 @@ tried_cmd = TRUE; ret = c->func(conv, cmd, args, &err, c->data); if (ret == GAIM_CMD_RET_CONTINUE) { - if (err) - g_free(err); + g_free(err); err = NULL; - gaim_cmd_free_args(args); + g_strfreev(args); args = NULL; continue; } else { @@ -280,8 +271,7 @@ } - if (args) - gaim_cmd_free_args(args); + g_strfreev(args); g_free(cmd); g_free(mrest); Modified: trunk/src/connection.c =================================================================== --- trunk/src/connection.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/connection.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -337,10 +337,8 @@ { g_return_if_fail(gc != NULL); - if (gc->display_name != NULL) - g_free(gc->display_name); - - gc->display_name = (name == NULL ? NULL : g_strdup(name)); + g_free(gc->display_name); + gc->display_name = g_strdup(name); } GaimConnectionState Modified: trunk/src/conversation.c =================================================================== --- trunk/src/conversation.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/conversation.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -335,7 +335,6 @@ GaimConversationUiOps *ops; GaimConnection *gc; const char *name; - GList *node; g_return_if_fail(conv != NULL); @@ -433,34 +432,22 @@ } else if (conv->type == GAIM_CONV_TYPE_CHAT) { - for (node = conv->u.chat->in_room; node != NULL; node = node->next) { - if (node->data != NULL) - gaim_conv_chat_cb_destroy((GaimConvChatBuddy *)node->data); - node->data = NULL; - } - - for (node = conv->u.chat->ignored; node != NULL; node = node->next) { - if (node->data != NULL) - g_free(node->data); - node->data = NULL; - } - + g_list_foreach(conv->u.chat->in_room, (GFunc)gaim_conv_chat_cb_destroy, NULL); g_list_free(conv->u.chat->in_room); + + g_list_foreach(conv->u.chat->ignored, (GFunc)g_free, NULL); g_list_free(conv->u.chat->ignored); conv->u.chat->in_room = NULL; conv->u.chat->ignored = NULL; - if (conv->u.chat->who != NULL) - g_free(conv->u.chat->who); + g_free(conv->u.chat->who); conv->u.chat->who = NULL; - if (conv->u.chat->topic != NULL) - g_free(conv->u.chat->topic); + g_free(conv->u.chat->topic); conv->u.chat->topic = NULL; - if(conv->u.chat->nick) - g_free(conv->u.chat->nick); + g_free(conv->u.chat->nick); GAIM_DBUS_UNREGISTER_POINTER(conv->u.chat); g_free(conv->u.chat); @@ -587,9 +574,7 @@ g_return_if_fail(conv != NULL); g_return_if_fail(title != NULL); - if (conv->title != NULL) - g_free(conv->title); - + g_free(conv->title); conv->title = g_strdup(title); gaim_conversation_update(conv, GAIM_CONV_UPDATE_TITLE); @@ -651,11 +636,9 @@ { g_return_if_fail(conv != NULL); - if (conv->name != NULL) - g_free(conv->name); + g_free(conv->name); + conv->name = g_strdup(name); - conv->name = (name == NULL ? NULL : g_strdup(name)); - gaim_conversation_autoset_title(conv); } @@ -1326,11 +1309,11 @@ { g_return_if_fail(chat != NULL); - if (chat->who != NULL) g_free(chat->who); - if (chat->topic != NULL) g_free(chat->topic); + g_free(chat->who); + g_free(chat->topic); - chat->who = (who == NULL ? NULL : g_strdup(who)); - chat->topic = (topic == NULL ? NULL : g_strdup(topic)); + chat->who = g_strdup(who); + chat->topic = g_strdup(topic); gaim_conversation_update(gaim_conv_chat_get_conversation(chat), GAIM_CONV_UPDATE_TOPIC); @@ -1447,7 +1430,6 @@ char *user1 = NULL, *user2 = NULL; gint ret = 0; - if (a) { f1 = a->flags; if (a->alias_key) @@ -1455,7 +1437,7 @@ else if (a->name) user1 = a->name; } - + if (b) { f2 = b->flags; if (b->alias_key) @@ -1470,7 +1452,7 @@ } else if (f1 != f2) { /* sort more important users first */ ret = (f1 > f2) ? -1 : 1; - } else if (a->buddy != b->buddy) { + } else if (a->buddy != b->buddy) { ret = a->buddy ? -1 : 1; } else { ret = strcasecmp(user1, user2); @@ -1565,7 +1547,7 @@ } cbuddies = g_list_sort(cbuddies, (GCompareFunc)gaim_conv_chat_cb_compare); - + if (ops != NULL && ops->chat_add_users != NULL) ops->chat_add_users(conv, cbuddies, new_arrivals); @@ -1728,7 +1710,7 @@ } /* NOTE: Don't remove them from ignored in case they re-enter. */ - + if (!quiet) { const char *alias = user; char *escaped; @@ -1866,8 +1848,7 @@ void gaim_conv_chat_set_nick(GaimConvChat *chat, const char *nick) { g_return_if_fail(chat != NULL); - if(chat->nick) - g_free(chat->nick); + g_free(chat->nick); chat->nick = g_strdup(gaim_normalize(chat->conv->account, nick)); } @@ -1920,10 +1901,7 @@ cb = g_new0(GaimConvChatBuddy, 1); cb->name = g_strdup(name); cb->flags = flags; - if (alias) - cb->alias = g_strdup(alias); - else - cb->alias = NULL; + cb->alias = g_strdup(alias); GAIM_DBUS_REGISTER_POINTER(cb, GaimConvChatBuddy); return cb; @@ -1950,15 +1928,12 @@ void gaim_conv_chat_cb_destroy(GaimConvChatBuddy *cb) { - g_return_if_fail(cb != NULL); + if (cb == NULL) + return; g_free(cb->alias); g_free(cb->alias_key); g_free(cb->name); - cb->name = NULL; - cb->alias = NULL; - cb->alias_key = NULL; - cb->flags = 0; GAIM_DBUS_UNREGISTER_POINTER(cb); g_free(cb); Modified: trunk/src/core.c =================================================================== --- trunk/src/core.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/core.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -196,11 +196,7 @@ gaim_dbus_uninit(); #endif - if (core->ui != NULL) { - g_free(core->ui); - core->ui = NULL; - } - + g_free(core->ui); g_free(core); _core = NULL; Modified: trunk/src/dbus-define-api.h =================================================================== --- trunk/src/dbus-define-api.h 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/dbus-define-api.h 2006-08-05 08:27:39 UTC (rev 16638) @@ -7,10 +7,10 @@ /* blist.h */ gboolean GAIM_BLIST_NODE_IS_CHAT(GaimBlistNode *node); -gboolean GAIM_BLIST_NODE_IS_BUDDY(GaimBlistNode *node); +gboolean GAIM_BLIST_NODE_IS_BUDDY(GaimBlistNode *node); gboolean GAIM_BLIST_NODE_IS_CONTACT(GaimBlistNode *node); gboolean GAIM_BLIST_NODE_IS_GROUP(GaimBlistNode *node); -gboolean GAIM_BUDDY_IS_ONLINE(GaimBuddy *buddy); +gboolean GAIM_BUDDY_IS_ONLINE(GaimBuddy *buddy); gboolean GAIM_BLIST_NODE_HAS_FLAG(GaimBlistNode *node, int flags); gboolean GAIM_BLIST_NODE_SHOULD_SAVE(GaimBlistNode *node); Modified: trunk/src/dbus-server.h =================================================================== --- trunk/src/dbus-server.h 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/dbus-server.h 2006-08-05 08:27:39 UTC (rev 16638) @@ -32,7 +32,7 @@ G_BEGIN_DECLS -/** +/** Types of pointers are identified by the ADDRESS of a GaimDbusType object. This way, plugins can easily access types defined in gaim proper as well as introduce their own types that will not conflict @@ -41,7 +41,7 @@ The structure GaimDbusType has only one element (GaimDBusType::parent), a contains a pointer to the parent type, or @c NULL if the type has no parent. Parent means the same as the base class in object oriented - programming. + programming. */ typedef struct _GaimDBusType GaimDBusType; @@ -98,7 +98,7 @@ In order for an object to participate in the scheme, it must register itself and its type with the engine. This registration allocates an integer id which can be resolved to the pointer and - back. + back. Handles are not persistent. They are reissued every time gaim is started. This is not good; external applications that use gaim @@ -108,14 +108,14 @@ Pointer registration is only a temporary solution. When GaimBuddy and similar structures have been converted into gobjects, this registration will be done automatically by objects themselves. - + By the way, this kind of object-handle translation should be so common that there must be a library (maybe even glib) that implements it. I feel a bit like reinventing the wheel here. */ void gaim_dbus_init_ids(void); -/** +/** Registers a typed pointer. @param node The pointer to register. @@ -123,7 +123,7 @@ */ void gaim_dbus_register_pointer(gpointer node, GaimDBusType *type); -/** +/** Unregisters a pointer previously registered with gaim_dbus_register_pointer. @@ -142,7 +142,7 @@ the types of the parameters. @param vargs A va_list containing the actual parameters. */ -void gaim_dbus_signal_emit_gaim(const char *name, int num_values, +void gaim_dbus_signal_emit_gaim(const char *name, int num_values, GaimValue **values, va_list vargs); /** @@ -191,7 +191,7 @@ #define DBUS_EXPORT -/* +/* Here we include the list of #GAIM_DBUS_DECLARE_TYPE statements for all structs defined in gaim. This file has been generated by the #dbus-analize-types.py script. Modified: trunk/src/dbus-useful.c =================================================================== --- trunk/src/dbus-useful.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/dbus-useful.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -7,47 +7,47 @@ GaimAccount * -gaim_accounts_find_ext(const char *name, const char *protocol_id, +gaim_accounts_find_ext(const char *name, const char *protocol_id, gboolean (*account_test)(const GaimAccount *account)) { - GaimAccount *result = NULL; - GList *l; - char *who; - - if (name) - who = g_strdup(gaim_normalize(NULL, name)); - else - who = NULL; - - for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { - GaimAccount *account = (GaimAccount *)l->data; - - if (who && strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who)) - continue; + GaimAccount *result = NULL; + GList *l; + char *who; - if (protocol_id && strcmp(account->protocol_id, protocol_id)) - continue; + if (name) + who = g_strdup(gaim_normalize(NULL, name)); + else + who = NULL; - if (account_test && !account_test(account)) - continue; + for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { + GaimAccount *account = (GaimAccount *)l->data; - result = account; - break; - } + if (who && strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who)) + continue; - g_free(who); + if (protocol_id && strcmp(account->protocol_id, protocol_id)) + continue; - return result; + if (account_test && !account_test(account)) + continue; + + result = account; + break; + } + + g_free(who); + + return result; } -GaimAccount *gaim_accounts_find_any(const char *name, const char *protocol) +GaimAccount *gaim_accounts_find_any(const char *name, const char *protocol) { - return gaim_accounts_find_ext(name, protocol, NULL); + return gaim_accounts_find_ext(name, protocol, NULL); } -GaimAccount *gaim_accounts_find_connected(const char *name, const char *protocol) +GaimAccount *gaim_accounts_find_connected(const char *name, const char *protocol) { - return gaim_accounts_find_ext(name, protocol, gaim_account_is_connected); + return gaim_accounts_find_ext(name, protocol, gaim_account_is_connected); } Modified: trunk/src/dbus-useful.h =================================================================== --- trunk/src/dbus-useful.h 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/dbus-useful.h 2006-08-05 08:27:39 UTC (rev 16638) @@ -1,6 +1,6 @@ #include "conversation.h" -GaimAccount *gaim_accounts_find_ext(const char *name, const char *protocol_id, +GaimAccount *gaim_accounts_find_ext(const char *name, const char *protocol_id, gboolean (*account_test)(const GaimAccount *account)); GaimAccount *gaim_accounts_find_any(const char *name, const char *protocol); Modified: trunk/src/ft.c =================================================================== --- trunk/src/ft.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/ft.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -648,11 +648,7 @@ g_return_if_fail(xfer != NULL); g_free(xfer->message); - - if (message != NULL) - xfer->message = g_strdup(message); - else - xfer->message = NULL; + xfer->message = g_strdup(message); } void @@ -660,10 +656,8 @@ { g_return_if_fail(xfer != NULL); - if (xfer->filename != NULL) - g_free(xfer->filename); - - xfer->filename = (filename == NULL ? NULL : g_strdup(filename)); + g_free(xfer->filename); + xfer->filename = g_strdup(filename); } void @@ -671,10 +665,8 @@ { g_return_if_fail(xfer != NULL); - if (xfer->local_filename != NULL) - g_free(xfer->local_filename); - - xfer->local_filename = (filename == NULL ? NULL : g_strdup(filename)); + g_free(xfer->local_filename); + xfer->local_filename = g_strdup(filename); } void Modified: trunk/src/gaim-client-example.c =================================================================== --- trunk/src/gaim-client-example.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gaim-client-example.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -5,7 +5,7 @@ #include "gaim-client.h" -/* +/* This example demonstrates how to use libgaim-client to communicate with gaim. The names and signatures of functions provided by libgaim-client are the same as those in gaim. However, all @@ -21,19 +21,19 @@ int main (int argc, char **argv) { - GList *alist, *node; + GList *alist, *node; - gaim_init(); - - alist = gaim_accounts_get_all(); - for (node = alist; node; node = node->next) { - GaimAccount *account = (GaimAccount*) node->data; - char *name = gaim_account_get_username(account); - g_print("Name: %s\n", name); - g_free(name); - } + gaim_init(); - g_list_free(alist); + alist = gaim_accounts_get_all(); + for (node = alist; node != NULL; node = node->next) + { + GaimAccount *account = (GaimAccount*) node->data; + char *name = gaim_account_get_username(account); + g_print("Name: %s\n", name); + g_free(name); + } + g_list_free(alist); - return 0; + return 0; } Modified: trunk/src/gaim-client.c =================================================================== --- trunk/src/gaim-client.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gaim-client.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -10,69 +10,72 @@ static DBusGConnection *bus; static DBusGProxy *gaim_proxy; -static GList *garray_int_to_glist(GArray *array) { - GList *list = NULL; - int i; +static GList *garray_int_to_glist(GArray *array) +{ + GList *list = NULL; + int i; - for(i = 0; i < array->len; i++) - list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i))); + for (i = 0; i < array->len; i++) + list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i))); - g_array_free(array, TRUE); - return list; + g_array_free(array, TRUE); + return list; } -static GSList *garray_int_to_gslist(GArray *array) { - GSList *list = NULL; - int i; +static GSList *garray_int_to_gslist(GArray *array) +{ + GSList *list = NULL; + int i; - for(i = 0; i < array->len; i++) - list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i))); + for (i = 0; i < array->len; i++) + list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i))); - g_array_free(array, TRUE); - return list; + g_array_free(array, TRUE); + return list; } #include "gaim-client-bindings.c" -static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2); -static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN; +static void lose(const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2); +static void lose_gerror(const char *prefix, GError *error) G_GNUC_NORETURN; static void -lose (const char *str, ...) +lose(const char *str, ...) { - va_list args; + va_list args; - va_start (args, str); + va_start(args, str); - vfprintf (stderr, str, args); - fputc ('\n', stderr); + vfprintf(stderr, str, args); + fputc('\n', stderr); - va_end (args); + va_end(args); - exit (1); + exit(1); } static void -lose_gerror (const char *prefix, GError *error) +lose_gerror(const char *prefix, GError *error) { - lose ("%s: %s", prefix, error->message); + lose("%s: %s", prefix, error->message); } -void gaim_init(void) { - GError *error = NULL; +void gaim_init(void) +{ + GError *error = NULL; - g_type_init (); + g_type_init (); - bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (!bus) - lose_gerror ("Couldn't connect to session bus", error); + bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (!bus) + lose_gerror ("Couldn't connect to session bus", error); - gaim_proxy = dbus_g_proxy_new_for_name (bus, - DBUS_SERVICE_GAIM, - DBUS_PATH_GAIM, - DBUS_INTERFACE_GAIM); + gaim_proxy = dbus_g_proxy_new_for_name (bus, + DBUS_SERVICE_GAIM, + DBUS_PATH_GAIM, + DBUS_INTERFACE_GAIM); - if (!gaim_proxy) - lose_gerror ("Couldn't connect to the Gaim Service", error); + if (!gaim_proxy) + lose_gerror ("Couldn't connect to the Gaim Service", error); } Modified: trunk/src/gtkaccount.c =================================================================== --- trunk/src/gtkaccount.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkaccount.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -204,7 +204,7 @@ gaim_gtk_buddy_icon_get_scale_size(pixbuf, &dialog->prpl_info->icon_spec, &width, &height); scale = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR); - + g_object_unref(G_OBJECT(pixbuf)); pixbuf = scale; } @@ -231,9 +231,7 @@ { dialog->prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(dialog->plugin); - if (dialog->protocol_id != NULL) - g_free(dialog->protocol_id); - + g_free(dialog->protocol_id); dialog->protocol_id = g_strdup(dialog->plugin->info->id); } @@ -317,8 +315,7 @@ #endif /* FILECHOOSER */ - if (dialog->icon_path) - g_free(dialog->icon_path); + g_free(dialog->icon_path); dialog->icon_path = convert_buddy_icon(dialog->plugin, filename); set_dialog_icon(dialog); gtk_widget_show(dialog->icon_entry); @@ -482,8 +479,7 @@ static void icon_reset_cb(GtkWidget *button, AccountPrefsDialog *dialog) { - if (dialog->icon_path) - g_free(dialog->icon_path); + g_free(dialog->icon_path); dialog->icon_path = NULL; gtk_widget_hide(dialog->icon_entry); @@ -512,8 +508,7 @@ } if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) *rtmp = '\0'; - if (dialog->icon_path) - g_free(dialog->icon_path); + g_free(dialog->icon_path); dialog->icon_path = convert_buddy_icon(dialog->plugin, tmp); set_dialog_icon(dialog); gtk_widget_show(dialog->icon_entry); @@ -1423,15 +1418,10 @@ gtk_widget_destroy(dialog->window); - if (dialog->user_split_entries != NULL) - g_list_free(dialog->user_split_entries); + g_list_free(dialog->user_split_entries); + g_list_free(dialog->protocol_opt_entries); + g_free(dialog->protocol_id); - if (dialog->protocol_opt_entries != NULL) - g_list_free(dialog->protocol_opt_entries); - - if (dialog->protocol_id != NULL) - g_free(dialog->protocol_id); - if (dialog->icon_path != NULL) { const char *icon = gaim_account_get_buddy_icon(dialog->account); @@ -2572,10 +2562,7 @@ free_add_user_data(GaimGtkAccountAddUserData *data) { g_free(data->username); - - if (data->alias != NULL) - g_free(data->alias); - + g_free(data->alias); g_free(data); } @@ -2645,7 +2632,7 @@ data = g_new0(GaimGtkAccountAddUserData, 1); data->account = account; data->username = g_strdup(remote_user); - data->alias = (alias != NULL ? g_strdup(alias) : NULL); + data->alias = g_strdup(alias); buffer = make_info(account, gc, remote_user, id, alias, msg); Modified: trunk/src/gtkblist.c =================================================================== --- trunk/src/gtkblist.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkblist.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -553,9 +553,7 @@ ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); } - if (data->entries != NULL) - g_list_free(data->entries); - + g_list_free(data->entries); data->entries = NULL; if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) @@ -1519,8 +1517,7 @@ if (aims == NULL && icqs == NULL && yahoos == NULL && msns == NULL && jabbers == NULL) { - if (alias != NULL) - g_free(alias); + g_free(alias); return FALSE; } @@ -1531,8 +1528,7 @@ add_buddies_from_vcard("prpl-msn", group, msns, alias); add_buddies_from_vcard("prpl-jabber", group, jabbers, alias); - if (alias != NULL) - g_free(alias); + g_free(alias); return TRUE; } @@ -1594,7 +1590,6 @@ GValue val; GString *str; const char *protocol; - char *mime_str; ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); sourcerow = gtk_tree_row_reference_get_path(ref); @@ -1654,15 +1649,13 @@ str = g_string_append(str, "\r\n"); - mime_str = g_string_free(str, FALSE); - gtk_selection_data_set(data, gdk_atom_intern("application/x-im-contact", FALSE), 8, /* bits */ - (const guchar *)mime_str, - strlen(mime_str) + 1); + (const guchar *)str->str, + strlen(str->str) + 1); - g_free(mime_str); + g_string_free(str, TRUE); gtk_tree_path_free(sourcerow); } } @@ -1878,9 +1871,9 @@ } } - if (username != NULL) g_free(username); - if (protocol != NULL) g_free(protocol); - if (alias != NULL) g_free(alias); + g_free(username); + g_free(protocol); + g_free(alias); if (path != NULL) gtk_tree_path_free(path); @@ -2966,7 +2959,7 @@ statustext = g_strdup(_("Offline")); else if (!statustext) text = g_strdup(esc); - + if (gaim_presence_is_idle(presence)) { if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")) { time_t idle_secs = gaim_presence_get_idle_time(presence); @@ -3017,7 +3010,7 @@ } /* It is selected. */ - if ((selected && !text) || (selected && idletime)) + if ((selected && !text) || (selected && idletime)) text = g_strdup_printf("%s\n" "<span size='smaller'>%s%s%s</span>", esc, @@ -3072,7 +3065,7 @@ if (gtk_blist_obscured || !GTK_WIDGET_VISIBLE(gtkblist->window)) return TRUE; - + for(gnode = list->root; gnode; gnode = gnode->next) { if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; @@ -3084,7 +3077,7 @@ if (buddy && gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) - gaim_gtk_blist_update_contact(list, (GaimBlistNode*)buddy); + gaim_gtk_blist_update_contact(list, (GaimBlistNode*)buddy); } } } @@ -4246,7 +4239,7 @@ contact = (GaimContact*)cnode; buddy = gaim_contact_get_priority_buddy(contact); - + if (buddy_is_displayable(buddy)) { GtkTreeIter iter; @@ -4294,10 +4287,10 @@ g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); if (node->parent == NULL) - return; + return; buddy = (GaimBuddy*)node; - + /* First things first, update the contact */ gaim_gtk_blist_update_contact(list, node); @@ -4800,8 +4793,7 @@ ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); } - if (data->entries != NULL) - g_list_free(data->entries); + g_list_free(data->entries); data->entries = NULL; @@ -5833,7 +5825,7 @@ submenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); gtk_widget_show(submenu); - + gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); path = g_strdup_printf("%s/Tools/%s", gtkblist->ift->path, plugin->info->name); gtk_menu_set_accel_path(GTK_MENU(submenu), path); Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkconv.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -193,15 +193,9 @@ static gint close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) { - GList *list = g_list_copy(gtkconv->convs), *l; + GList *list = g_list_copy(gtkconv->convs); - l = list; - while (l) { - GaimConversation *conv = l->data; - gaim_conversation_destroy(conv); - l = l->next; - } - + g_list_foreach(list, (GFunc)gaim_conversation_destroy, NULL); g_list_free(list); return TRUE; @@ -489,8 +483,7 @@ case GAIM_CMD_STATUS_FAILED: gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), GAIM_MESSAGE_NO_LOG, time(NULL)); - if(error) - g_free(error); + g_free(error); return TRUE; case GAIM_CMD_STATUS_WRONG_TYPE: if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) @@ -771,8 +764,8 @@ } } - if (username != NULL) g_free(username); - if (protocol != NULL) g_free(protocol); + g_free(username); + g_free(protocol); gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); } @@ -1426,7 +1419,7 @@ gaim_conv_chat_ignore(chat, name); cbuddy = gaim_conv_chat_cb_new(name, alias, flags); - + add_chat_buddy_common(conv, cbuddy, NULL); g_free(name); g_free(alias); @@ -1525,7 +1518,7 @@ who = g_object_get_data(G_OBJECT(w), "user_data"); mark = get_mark_for_user(gtkconv, who); - + if (mark != NULL) gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); else @@ -3214,8 +3207,7 @@ GaimBlistNode *gnode,*cnode,*bnode; static GList *tmp = NULL; - if (tmp) - g_list_free(tmp); + g_list_free(tmp); tmp = g_list_append(NULL, ""); @@ -4261,8 +4253,8 @@ } } - if (username != NULL) g_free(username); - if (protocol != NULL) g_free(protocol); + g_free(username); + g_free(protocol); gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); } @@ -4868,8 +4860,7 @@ } } - if(alias_escaped) - g_free(alias_escaped); + g_free(alias_escaped); /* Are we in a chat where we can tell which users are buddies? */ if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && @@ -5070,7 +5061,7 @@ g_return_if_fail(new_alias != NULL); cbuddy = gaim_conv_chat_cb_new(new_name, new_alias, flags); - + add_chat_buddy_common(conv, cbuddy, old_name); } @@ -5177,7 +5168,7 @@ flags = gaim_conv_chat_user_get_flags(chat, user); cbuddy = gaim_conv_chat_cb_new(user, alias, flags); - + add_chat_buddy_common(conv, cbuddy, NULL); g_free(alias); } Modified: trunk/src/gtkdebug.c =================================================================== --- trunk/src/gtkdebug.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkdebug.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -58,9 +58,9 @@ gboolean invert; gboolean highlight; - + guint timer; - + regex_t regex; #else GtkWidget *find; @@ -351,8 +351,8 @@ for(m = 0; m < n_matches; m++) { GtkTextIter ms, me; - - if(matches[m].rm_eo == -1) + + if(matches[m].rm_eo == -1) break; i += offset; @@ -524,7 +524,7 @@ */ if(win->paused) return; - + gtk_tree_model_get(model, iter, 0, &text, -1); if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { @@ -840,8 +840,7 @@ g_free(new_msg); } - if (new_domain != NULL) - g_free(new_domain); + g_free(new_domain); } #ifdef _WIN32 Modified: trunk/src/gtkft.c =================================================================== --- trunk/src/gtkft.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkft.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -1097,8 +1097,7 @@ data = GAIM_GTKXFER(xfer); if (data) { - if (data->name) - g_free(data->name); + g_free(data->name); g_free(data); xfer->ui_data = NULL; } Modified: trunk/src/gtkimhtml.c =================================================================== --- trunk/src/gtkimhtml.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkimhtml.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -1248,10 +1248,8 @@ g_list_free(imhtml->scalables); g_slist_free(imhtml->im_images); - if (imhtml->protocol_name) - g_free(imhtml->protocol_name); - if (imhtml->search_string) - g_free(imhtml->search_string); + g_free(imhtml->protocol_name); + g_free(imhtml->search_string); G_OBJECT_CLASS(parent_class)->finalize (object); } @@ -2737,8 +2735,7 @@ gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); ws[0] = '\0'; wpos = 0; /* NEW_BIT(NEW_TEXT_BIT); */ - if (bg) - g_free(bg); + g_free(bg); bg = bgcolor; gtk_imhtml_toggle_background(imhtml, bg); } @@ -2752,8 +2749,7 @@ ws[0] = '\0'; wpos = 0; gtk_imhtml_toggle_link(imhtml, href); } - if (href) - g_free(href); + g_free(href); } break; case 46: /* IMG (opt) */ @@ -3037,14 +3033,10 @@ while (fonts) { GtkIMHtmlFontDetail *font = fonts->data; fonts = g_slist_remove (fonts, font); - if (font->face) - g_free (font->face); - if (font->fore) - g_free (font->fore); - if (font->back) - g_free (font->back); - if (font->sml) - g_free (font->sml); + g_free (font->face); + g_free (font->fore); + g_free (font->back); + g_free (font->sml); g_free (font); } @@ -3082,9 +3074,8 @@ void gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, const gchar *protocol_name) { - if (imhtml->protocol_name) - g_free(imhtml->protocol_name); - imhtml->protocol_name = protocol_name ? g_strdup(protocol_name) : NULL; + g_free(imhtml->protocol_name); + imhtml->protocol_name = g_strdup(protocol_name); } void @@ -3174,7 +3165,7 @@ im_image->width = gdk_pixbuf_get_width(img); im_image->height = gdk_pixbuf_get_height(img); im_image->mark = NULL; - im_image->filename = filename ? g_strdup(filename) : NULL; + im_image->filename = g_strdup(filename); im_image->id = id; im_image->filesel = NULL; @@ -3441,8 +3432,7 @@ GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; g_object_unref(image->pixbuf); - if (image->filename) - g_free(image->filename); + g_free(image->filename); if (image->filesel) gtk_widget_destroy(image->filesel); g_free(scale); @@ -3559,8 +3549,7 @@ gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &start, &end); - if (imhtml->search_string) - g_free(imhtml->search_string); + g_free(imhtml->search_string); imhtml->search_string = NULL; } @@ -3825,7 +3814,7 @@ strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { gtk_imhtml_toggle_link(imhtml, NULL); } - } + } } g_slist_free(tags); } @@ -3944,37 +3933,25 @@ char * gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) { - if (imhtml->edit.fontface) - return g_strdup(imhtml->edit.fontface); - else - return NULL; + return g_strdup(imhtml->edit.fontface); } char * gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) { - if (imhtml->edit.forecolor) - return g_strdup(imhtml->edit.forecolor); - else - return NULL; + return g_strdup(imhtml->edit.forecolor); } char * gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) { - if (imhtml->edit.backcolor) - return g_strdup(imhtml->edit.backcolor); - else - return NULL; + return g_strdup(imhtml->edit.backcolor); } char * gtk_imhtml_get_current_background(GtkIMHtml *imhtml) { - if (imhtml->edit.background) - return g_strdup(imhtml->edit.background); - else - return NULL; + return g_strdup(imhtml->edit.background); } gint @@ -4029,15 +4006,15 @@ return; imhtml->edit.bold = imhtml->edit.italic = imhtml->edit.underline = imhtml->edit.strike = FALSE; - if (imhtml->edit.forecolor) - g_free(imhtml->edit.forecolor); + g_free(imhtml->edit.forecolor); imhtml->edit.forecolor = NULL; - if (imhtml->edit.backcolor) - g_free(imhtml->edit.backcolor); + + g_free(imhtml->edit.backcolor); imhtml->edit.backcolor = NULL; - if (imhtml->edit.fontface) - g_free(imhtml->edit.fontface); + + g_free(imhtml->edit.fontface); imhtml->edit.fontface = NULL; + imhtml->edit.fontsize = 0; imhtml->edit.link = NULL; Modified: trunk/src/gtkimhtmltoolbar.c =================================================================== --- trunk/src/gtkimhtmltoolbar.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkimhtmltoolbar.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -878,8 +878,7 @@ toolbar); } - if (toolbar->sml) - free(toolbar->sml); + free(toolbar->sml); gtk_object_sink(GTK_OBJECT(toolbar->tooltips)); G_OBJECT_CLASS(parent_class)->finalize (object); @@ -1132,8 +1131,6 @@ void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id) { - if (toolbar->sml) - g_free(toolbar->sml); - + g_free(toolbar->sml); toolbar->sml = g_strdup(proto_id); } Modified: trunk/src/gtklog.c =================================================================== --- trunk/src/gtklog.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtklog.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -111,8 +111,7 @@ const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); GList *logs; - if (lv->search != NULL) - g_free(lv->search); + g_free(lv->search); gtk_tree_store_clear(lv->treestore); if (!(*search_term)) { @@ -154,9 +153,7 @@ lv = g_hash_table_lookup(log_viewers, ht); g_hash_table_remove(log_viewers, ht); - if (ht->screenname != NULL) - g_free(ht->screenname); - + g_free(ht->screenname); g_free(ht); } else syslog_viewer = NULL; @@ -164,10 +161,9 @@ g_list_foreach(lv->logs, (GFunc)gaim_log_free, NULL); g_list_free(lv->logs); - if (lv->search != NULL) - g_free(lv->search); - + g_free(lv->search); g_free(lv); + gtk_widget_destroy(w); return TRUE; Modified: trunk/src/gtkpluginpref.c =================================================================== --- trunk/src/gtkpluginpref.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkpluginpref.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -57,9 +57,6 @@ g_return_if_fail(pref); text = gtk_imhtml_get_markup(imhtml); - - if (!text) - text = ""; gaim_prefs_set_string(pref, text); g_free(text); } Modified: trunk/src/gtkpounce.c =================================================================== --- trunk/src/gtkpounce.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkpounce.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -432,8 +432,8 @@ } } - if (username != NULL) g_free(username); - if (protocol != NULL) g_free(protocol); + g_free(username); + g_free(protocol); gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); } @@ -1195,7 +1195,7 @@ /* Create the scrolled window */ sw = gtk_scrolled_window_new(0, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); Modified: trunk/src/gtkprefs.c =================================================================== --- trunk/src/gtkprefs.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkprefs.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -1474,7 +1474,7 @@ static gchar* prefs_sound_volume_format(GtkScale *scale, gdouble val) { if(val < 15) { - return g_strdup_printf(_("Quietest")); + return g_strdup_printf(_("Quietest")); } else if(val < 30) { return g_strdup_printf(_("Quieter")); } else if(val < 45) { Modified: trunk/src/gtkprivacy.c =================================================================== --- trunk/src/gtkprivacy.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkprivacy.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -7,7 +7,7 @@ * Gaim is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -521,9 +521,7 @@ static void destroy_request_data(GaimGtkPrivacyRequestData *data) { - if (data->name != NULL) - g_free(data->name); - + g_free(data->name); g_free(data); } Modified: trunk/src/gtkrequest.c =================================================================== --- trunk/src/gtkrequest.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkrequest.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -364,7 +364,7 @@ /* Entry field. */ data->u.input.multiline = multiline; - data->u.input.hint = (hint == NULL ? NULL : g_strdup(hint)); + data->u.input.hint = g_strdup(hint); if ((data->u.input.hint != NULL) && (!strcmp(data->u.input.hint, "html"))) { GtkWidget *frame; @@ -1586,7 +1586,7 @@ { GaimGtkRequestData *data; GtkWidget *dirsel; - + data = g_new0(GaimGtkRequestData, 1); data->type = GAIM_REQUEST_FOLDER; data->user_data = user_data; @@ -1633,8 +1633,7 @@ { GaimGtkRequestData *data = (GaimGtkRequestData *)ui_handle; - if (data->cbs != NULL) - g_free(data->cbs); + g_free(data->cbs); gtk_widget_destroy(data->dialog); Modified: trunk/src/gtkroomlist.c =================================================================== --- trunk/src/gtkroomlist.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkroomlist.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -593,7 +593,7 @@ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(selection_changed_cb), grl); - + g_object_unref(model); grl->model = model; Modified: trunk/src/gtksound.c =================================================================== --- trunk/src/gtksound.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtksound.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -342,7 +342,7 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, - gpointer data) + gpointer data) { GstElement *play = data; GError *err; @@ -443,17 +443,17 @@ uri = g_strdup_printf("file://%s", filename); play = gst_element_factory_make("playbin", "play"); - + g_object_set(G_OBJECT(play), "uri", uri, - "volume", volume, + "volume", volume, "audio-sink", sink, NULL); gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(play)), bus_call, play); gst_element_set_state(play, GST_STATE_PLAYING); - + g_free(uri); - + #else /* USE_GSTREAMER */ gdk_beep(); return; @@ -499,7 +499,7 @@ if (gaim_prefs_get_bool(enable_pref)) { char *filename = g_strdup(gaim_prefs_get_string(file_pref)); if(!filename || !strlen(filename)) { - if(filename) g_free(filename); + g_free(filename); filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); } Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkstatusbox.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -751,7 +751,7 @@ status_menu_refresh_iter(status_box); return TRUE; } - + gtk_gaim_status_box_pulse_typing(status_box); g_source_remove(status_box->typing); status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); Modified: trunk/src/gtkthemes.c =================================================================== --- trunk/src/gtkthemes.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkthemes.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -119,23 +119,19 @@ theme->list = child; list = child; } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { - if(theme->name) - g_free(theme->name); + g_free(theme->name); theme->name = g_strdup(i+ strlen("Name=")); theme->name[strlen(theme->name)-1] = 0; } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { - if(theme->desc) - g_free(theme->desc); + g_free(theme->desc); theme->desc = g_strdup(i + strlen("Description=")); theme->desc[strlen(theme->desc)-1] = 0; } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { - if(theme->icon) - g_free(theme->icon); + g_free(theme->icon); theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); theme->icon[strlen(theme->icon)-1] = 0; } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { - if(theme->author) - g_free(theme->author); + g_free(theme->author); theme->author = g_strdup(i + strlen("Author=")); theme->author[strlen(theme->author)-1] = 0; } else if (load && list) { Modified: trunk/src/gtkutils.c =================================================================== --- trunk/src/gtkutils.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/gtkutils.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -1053,9 +1053,9 @@ { valid = FALSE; - if (username != NULL) g_free(username); - if (protocol != NULL) g_free(protocol); - if (alias != NULL) g_free(alias); + g_free(username); + g_free(protocol); + g_free(alias); } g_free(str); Modified: trunk/src/imgstore.c =================================================================== --- trunk/src/imgstore.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/imgstore.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -82,10 +82,8 @@ img = priv->img; if (img) { - if (img->data) - g_free(img->data); - if (img->filename) - g_free(img->filename); + g_free(img->data); + g_free(img->filename); g_free(img); } Modified: trunk/src/log.c =================================================================== --- trunk/src/log.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/log.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -110,7 +110,7 @@ log->tm->tm_zone = tmp; else /* Just shove the UTF-8 bytes in and hope... */ - log->tm->tm_zone = (char *)g_strdup(log->tm->tm_zone); + log->tm->tm_zone = g_strdup(log->tm->tm_zone); } #endif } @@ -853,7 +853,7 @@ for (account_iter = gaim_accounts_get_all() ; account_iter != NULL ; account_iter = account_iter->next) { GaimPlugin *prpl; GaimPluginProtocolInfo *prpl_info; - + prpl = gaim_find_prpl(gaim_account_get_protocol_id((GaimAccount *)account_iter->data)); if (!prpl) continue; @@ -1281,8 +1281,7 @@ if (data) { if(data->file) fclose(data->file); - if(data->path) - g_free(data->path); + g_free(data->path); g_slice_free(GaimLogCommonLoggerData, data); } Modified: trunk/src/notify.c =================================================================== --- trunk/src/notify.c 2006-08-05 05:44:34 UTC (rev 16637) +++ trunk/src/notify.c 2006-08-05 08:27:39 UTC (rev 16638) @@ -60,9 +60,9 @@ if (info->ui_handle != NULL) { handles = g_list_append(handles, info); - + return info->ui_handle; - + } else { if (info->cb != NULL) info->cb(info->cb_user_data); @@ -111,7 +111,7 @@ g_free(info); return NULL; - } + } } else { if (cb != NULL) cb(user_data); @@ -197,1... [truncated message content] |