pidgin: de954c20: Cleanup and avoid unnecessary alloc/free..
datallah at pidgin.im
datallah at pidgin.im
Fri May 2 19:21:10 EDT 2008
-----------------------------------------------------------------
Revision: de954c20849206de750b57c34fb04dd7b8a8833a
Ancestor: 1a8a740d833ae8da0fbc2f6c9a917909ca57eb8b
Author: datallah at pidgin.im
Date: 2008-05-02T23:16:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/de954c20849206de750b57c34fb04dd7b8a8833a
Modified files:
libpurple/notify.c
ChangeLog:
Cleanup and avoid unnecessary alloc/free.
-------------- next part --------------
============================================================
--- libpurple/notify.c 1dcecb63e5f9284c2ef99d6de37efd74bbd192e1
+++ libpurple/notify.c 3000cf372f054b1837f95032e814be09661582b4
@@ -66,35 +66,27 @@ purple_notify_message(void *handle, Purp
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_message != NULL) {
- PurpleNotifyInfo *info;
-
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_MESSAGE;
- info->handle = handle;
- info->ui_handle = ops->notify_message(type, title, primary,
+ void *ui_handle = ops->notify_message(type, title, primary,
secondary);
- info->cb = cb;
- info->cb_user_data = user_data;
+ if (ui_handle != NULL) {
- if (info->ui_handle != NULL) {
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_MESSAGE;
+ info->handle = handle;
+ info->ui_handle = ui_handle;
+ info->cb = cb;
+ info->cb_user_data = user_data;
+
handles = g_list_append(handles, info);
return info->ui_handle;
-
- } else {
- if (info->cb != NULL)
- info->cb(info->cb_user_data);
-
- g_free(info);
-
- return NULL;
}
- } else {
- if (cb != NULL)
- cb(user_data);
}
+ if (cb != NULL)
+ cb(user_data);
+
return NULL;
}
@@ -108,37 +100,31 @@ purple_notify_email(void *handle, const
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_email != NULL) {
- PurpleNotifyInfo *info;
+ void *ui_handle;
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_EMAIL;
- info->handle = handle;
+ purple_signal_emit(purple_notify_get_handle(), "displaying-email-notification",
+ subject, from, to, url);
- purple_signal_emit(purple_notify_get_handle(), "displaying-email-notification",
- subject, from, to, url);
+ ui_handle = ops->notify_email(handle, subject, from, to, url);
- info->ui_handle = ops->notify_email(handle, subject, from, to, url);
- info->cb = cb;
- info->cb_user_data = user_data;
+ if (ui_handle != NULL) {
- if (info->ui_handle != NULL) {
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_EMAIL;
+ info->handle = handle;
+ info->ui_handle = ui_handle;
+ info->cb = cb;
+ info->cb_user_data = user_data;
+
handles = g_list_append(handles, info);
return info->ui_handle;
-
- } else {
- if (info->cb != NULL)
- info->cb(info->cb_user_data);
-
- g_free(info);
-
- return NULL;
}
- } else {
- if (cb != NULL)
- cb(user_data);
}
+ if (cb != NULL)
+ cb(user_data);
+
return NULL;
}
@@ -162,39 +148,32 @@ purple_notify_emails(void *handle, size_
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_emails != NULL) {
- PurpleNotifyInfo *info;
+ void *ui_handle;
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_EMAILS;
- info->handle = handle;
-
purple_signal_emit(purple_notify_get_handle(), "displaying-emails-notification",
subjects, froms, tos, urls, count);
- info->ui_handle = ops->notify_emails(handle, count, detailed, subjects,
+ ui_handle = ops->notify_emails(handle, count, detailed, subjects,
froms, tos, urls);
- info->cb = cb;
- info->cb_user_data = user_data;
- if (info->ui_handle != NULL) {
+ if (ui_handle != NULL) {
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_EMAILS;
+ info->handle = handle;
+ info->ui_handle = ui_handle;
+ info->cb = cb;
+ info->cb_user_data = user_data;
+
handles = g_list_append(handles, info);
return info->ui_handle;
-
- } else {
- if (info->cb != NULL)
- info->cb(info->cb_user_data);
-
- g_free(info);
-
- return NULL;
}
- } else {
- if (cb != NULL)
- cb(user_data);
}
+ if (cb != NULL)
+ cb(user_data);
+
return NULL;
}
@@ -210,34 +189,25 @@ purple_notify_formatted(void *handle, co
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_formatted != NULL) {
- PurpleNotifyInfo *info;
+ void *ui_handle = ops->notify_formatted(title, primary, secondary, text);
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_FORMATTED;
- info->handle = handle;
- info->ui_handle = ops->notify_formatted(title, primary, secondary, text);
- info->cb = cb;
- info->cb_user_data = user_data;
+ if (ui_handle != NULL) {
- if (info->ui_handle != NULL) {
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_FORMATTED;
+ info->handle = handle;
+ info->ui_handle = ui_handle;
+ info->cb = cb;
+ info->cb_user_data = user_data;
+
handles = g_list_append(handles, info);
return info->ui_handle;
-
- } else {
- if (info->cb != NULL)
- info->cb(info->cb_user_data);
-
- g_free(info);
-
- return NULL;
}
-
- } else {
- if (cb != NULL)
- cb(user_data);
}
+ if (cb != NULL)
+ cb(user_data);
return NULL;
}
@@ -252,34 +222,25 @@ purple_notify_searchresults(PurpleConnec
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_searchresults != NULL) {
- PurpleNotifyInfo *info;
-
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_SEARCHRESULTS;
- info->handle = gc;
- info->ui_handle = ops->notify_searchresults(gc, title, primary,
+ void *ui_handle = ops->notify_searchresults(gc, title, primary,
secondary, results, user_data);
- info->cb = cb;
- info->cb_user_data = user_data;
+ if (ui_handle != NULL) {
- if (info->ui_handle != NULL) {
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_SEARCHRESULTS;
+ info->handle = gc;
+ info->ui_handle = ui_handle;
+ info->cb = cb;
+ info->cb_user_data = user_data;
+
handles = g_list_append(handles, info);
return info->ui_handle;
-
- } else {
- if (info->cb != NULL)
- info->cb(info->cb_user_data);
-
- g_free(info);
-
- return NULL;
}
+ }
- } else {
- if (cb != NULL)
- cb(user_data);
- }
+ if (cb != NULL)
+ cb(user_data);
return NULL;
}
@@ -449,37 +410,30 @@ purple_notify_userinfo(PurpleConnection
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_userinfo != NULL) {
- PurpleNotifyInfo *info;
+ void *ui_handle;
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_USERINFO;
- info->handle = gc;
-
purple_signal_emit(purple_notify_get_handle(), "displaying-userinfo",
purple_connection_get_account(gc), who, user_info);
- info->ui_handle = ops->notify_userinfo(gc, who, user_info);
- info->cb = cb;
- info->cb_user_data = user_data;
+ ui_handle = ops->notify_userinfo(gc, who, user_info);
- if (info->ui_handle != NULL) {
- handles = g_list_append(handles, info);
+ if (ui_handle != NULL) {
- return info->ui_handle;
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_USERINFO;
+ info->handle = gc;
+ info->ui_handle = ui_handle;
+ info->cb = cb;
+ info->cb_user_data = user_data;
- } else {
- if (info->cb != NULL)
- info->cb(info->cb_user_data);
+ handles = g_list_append(handles, info);
- g_free(info);
-
- return NULL;
+ return info->ui_handle;
}
+ }
- } else {
- if (cb != NULL)
- cb(user_data);
- }
+ if (cb != NULL)
+ cb(user_data);
return NULL;
}
@@ -705,22 +659,19 @@ purple_notify_uri(void *handle, const ch
ops = purple_notify_get_ui_ops();
if (ops != NULL && ops->notify_uri != NULL) {
- PurpleNotifyInfo *info;
- info = g_new0(PurpleNotifyInfo, 1);
- info->type = PURPLE_NOTIFY_URI;
- info->handle = handle;
- info->ui_handle = ops->notify_uri(uri);
+ void *ui_handle = ops->notify_uri(uri);
- if (info->ui_handle != NULL) {
+ if (ui_handle != NULL) {
+
+ PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
+ info->type = PURPLE_NOTIFY_URI;
+ info->handle = handle;
+ info->ui_handle = ui_handle;
+
handles = g_list_append(handles, info);
return info->ui_handle;
-
- } else {
- g_free(info);
-
- return NULL;
}
}
More information about the Commits
mailing list