/soc/2013/ankitkv/gobjectification: 38d1b844ddb6: Updated GBoxed...

Ankit Vani a at nevitus.org
Tue Jul 16 05:52:15 EDT 2013


Changeset: 38d1b844ddb634edf408f1eaf77ea03a839fc2a3
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-16 15:21 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/38d1b844ddb6

Description:

Updated GBoxed functions. Boxing is intended to be temporary for buddy list, saved status, plugins, status.

diffstat:

 libpurple/buddylist.c     |  10 +++++++---
 libpurple/buddylist.h     |   2 ++
 libpurple/connection.c    |   2 +-
 libpurple/savedstatuses.c |   6 +++++-
 libpurple/savedstatuses.h |   2 ++
 libpurple/status.c        |   6 +++++-
 libpurple/status.h        |   2 ++
 7 files changed, 24 insertions(+), 6 deletions(-)

diffs (101 lines):

diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -2051,10 +2051,14 @@ purple_blist_uninit(void)
 static PurpleBuddyList *
 purple_buddy_list_copy(PurpleBuddyList *blist)
 {
-	PurpleBuddyList *newlist = g_new(PurpleBuddyList, 1);
-	*newlist = *blist;
+	PurpleBuddyList *blist_copy;
 
-	return newlist;
+	g_return_val_if_fail(blist != NULL, NULL);
+
+	blist_copy = g_new(PurpleBuddyList, 1);
+	*blist_copy = *blist;
+
+	return blist_copy;
 }
 
 GType
diff --git a/libpurple/buddylist.h b/libpurple/buddylist.h
--- a/libpurple/buddylist.h
+++ b/libpurple/buddylist.h
@@ -125,6 +125,8 @@ G_BEGIN_DECLS
 
 /**
  * Returns the GType for the PurpleBuddyList boxed structure.
+ * TODO Boxing of PurpleBuddyList is a temporary solution to having a GType for
+ *      buddy list. This should rather be a GObject instead of a GBoxed.
  */
 GType purple_buddy_list_get_type(void);
 
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -570,7 +570,7 @@ purple_connection_error_info_copy(Purple
 	g_return_val_if_fail(err != NULL, NULL);
 
 	newerr = g_new(PurpleConnectionErrorInfo, 1);
-	*newerr = *err;
+	newerr->type        = err->type;
 	newerr->description = g_strdup(err->description);
 
 	return newerr;
diff --git a/libpurple/savedstatuses.c b/libpurple/savedstatuses.c
--- a/libpurple/savedstatuses.c
+++ b/libpurple/savedstatuses.c
@@ -1175,7 +1175,11 @@ purple_savedstatus_activate_for_account(
 static PurpleSavedStatus *
 purple_savedstatus_copy(PurpleSavedStatus *savedstatus)
 {
-	PurpleSavedStatus *savedstatus_copy = g_new(PurpleSavedStatus, 1);
+	PurpleSavedStatus *savedstatus_copy;
+
+	g_return_val_if_fail(savedstatus != NULL, NULL);
+
+	savedstatus_copy = g_new(PurpleSavedStatus, 1);
 	*savedstatus_copy = *savedstatus;
 
 	return savedstatus_copy;
diff --git a/libpurple/savedstatuses.h b/libpurple/savedstatuses.h
--- a/libpurple/savedstatuses.h
+++ b/libpurple/savedstatuses.h
@@ -70,6 +70,8 @@ G_BEGIN_DECLS
 
 /**
  * Returns the GType for the PurpleSavedStatus boxed structure.
+ * TODO Boxing of PurpleSavedStatus is a temporary solution to having a GType
+ *      for saved statuses. This should rather be a GObject instead of a GBoxed.
  */
 GType purple_savedstatus_get_type(void);
 
diff --git a/libpurple/status.c b/libpurple/status.c
--- a/libpurple/status.c
+++ b/libpurple/status.c
@@ -1057,7 +1057,11 @@ purple_status_compare(const PurpleStatus
 static PurpleStatus *
 purple_status_copy(PurpleStatus *status)
 {
-	PurpleStatus *status_copy = g_new(PurpleStatus, 1);
+	PurpleStatus *status_copy;
+
+	g_return_val_if_fail(status != NULL, NULL);
+
+	status_copy = g_new(PurpleStatus, 1);
 	*status_copy = *status;
 
 	return status_copy;
diff --git a/libpurple/status.h b/libpurple/status.h
--- a/libpurple/status.h
+++ b/libpurple/status.h
@@ -445,6 +445,8 @@ GValue *purple_status_attr_get_value(con
 
 /**
  * Returns the GType for the PurpleStatus boxed structure.
+ * TODO Boxing of PurpleStatus is a temporary solution to having a GType for
+ *      statuses. This should rather be a GObject instead of a GBoxed.
  */
 GType purple_status_get_type(void);
 



More information about the Commits mailing list