pidgin: 3879baf4: Use the unref functions everywhere, inst...

qulogic at pidgin.im qulogic at pidgin.im
Thu Dec 16 02:27:31 EST 2010


----------------------------------------------------------------------
Revision: 3879baf4c4d61a033a0b1aa98d65d4f735d3bf60
Parent:   b5d4c901be641477c7f650a03fb3fd5bdfc59896
Author:   qulogic at pidgin.im
Date:     12/15/10 18:10:13
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3879baf4c4d61a033a0b1aa98d65d4f735d3bf60

Changelog: 

Use the unref functions everywhere, instead of destroy. I also removed
some unnecessary checks in the destroy functions, since it's already
OK from the unref.

Changes against parent b5d4c901be641477c7f650a03fb3fd5bdfc59896

  patched  libpurple/protocols/msn/cmdproc.c
  patched  libpurple/protocols/msn/command.c
  patched  libpurple/protocols/msn/command.h
  patched  libpurple/protocols/msn/directconn.c
  patched  libpurple/protocols/msn/msg.c
  patched  libpurple/protocols/msn/slplink.c
  patched  libpurple/protocols/msn/slpmsg.c
  patched  libpurple/protocols/msn/slpmsg_part.c
  patched  libpurple/protocols/msn/slpmsg_part.h
  patched  libpurple/protocols/msn/user.c

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msg.c	f1ce1df7edd4caa9f8108c881f5ebc8c1cdc53bd
+++ libpurple/protocols/msn/msg.c	a3c0307d28dd10026e51f5c16bf992edefa4e4fb
@@ -70,7 +70,8 @@ msn_message_destroy(MsnMessage *msg)
 
 	g_hash_table_destroy(msg->header_table);
 	g_list_free(msg->header_list);
-	msn_slpmsgpart_destroy(msg->part);
+	if (msg->part)
+		msn_slpmsgpart_unref(msg->part);
 
 	g_free(msg);
 }
============================================================
--- libpurple/protocols/msn/user.c	62a071b9f81376d820c9f4ab67e04d40f883d328
+++ libpurple/protocols/msn/user.c	70a4e4faa17b021b8009ea9a2d838693dd1ca4b7
@@ -57,13 +57,6 @@ msn_user_destroy(MsnUser *user)
 static void
 msn_user_destroy(MsnUser *user)
 {
-	g_return_if_fail(user != NULL);
-
-	if (user->refcount > 1) {
-		msn_user_unref(user);
-		return;
-	}
-
 	while (user->endpoints != NULL) {
 		free_user_endpoint(user->endpoints->data);
 		user->endpoints = g_slist_delete_link(user->endpoints, user->endpoints);
============================================================
--- libpurple/protocols/msn/cmdproc.c	ec542c21b85fb7fa7536ddcb2474663c2beed301
+++ libpurple/protocols/msn/cmdproc.c	45f779a56031d8b4aec7ee5a743be61540d91335
@@ -58,7 +58,7 @@ msn_cmdproc_destroy(MsnCmdProc *cmdproc)
 	msn_history_destroy(cmdproc->history);
 
 	if (cmdproc->last_cmd != NULL)
-		msn_command_destroy(cmdproc->last_cmd);
+		msn_command_unref(cmdproc->last_cmd);
 
 	g_hash_table_destroy(cmdproc->multiparts);
 
@@ -329,7 +329,7 @@ msn_cmdproc_process_cmd_text(MsnCmdProc 
 	show_debug_cmd(cmdproc, TRUE, command);
 
 	if (cmdproc->last_cmd != NULL)
-		msn_command_destroy(cmdproc->last_cmd);
+		msn_command_unref(cmdproc->last_cmd);
 
 	cmdproc->last_cmd = msn_command_from_string(command);
 
============================================================
--- libpurple/protocols/msn/command.c	137736e73ccd9f23002ed2d5a771672626724bdc
+++ libpurple/protocols/msn/command.c	bbdb273d7e04a683dbc78bc5444cdb810fcc6226
@@ -79,20 +79,10 @@ msn_command_from_string(const char *stri
 	return cmd;
 }
 
-void
+static void
 msn_command_destroy(MsnCommand *cmd)
 {
-	g_return_if_fail(cmd != NULL);
-
-	if (cmd->ref_count > 0)
-	{
-		msn_command_unref(cmd);
-		return;
-	}
-
-	if (cmd->payload != NULL)
-		g_free(cmd->payload);
-
+	g_free(cmd->payload);
 	g_free(cmd->command);
 	g_strfreev(cmd->params);
 	g_free(cmd);
============================================================
--- libpurple/protocols/msn/command.h	42a7bc1d15979423b456f31ee060ee0340ccce09
+++ libpurple/protocols/msn/command.h	7c63be219082f802f0db075e7f5edcbba59b9603
@@ -64,14 +64,6 @@ MsnCommand *msn_command_from_string(cons
 MsnCommand *msn_command_from_string(const char *string);
 
 /**
- * Destroy a MsnCommand object if its ref count is zero, otherwise
- * just unref it.
- *
- * @param cmd 	The MsnCommand to be destroyed.
- */
-void msn_command_destroy(MsnCommand *cmd);
-
-/**
  * Increment the ref count.
  *
  * @param cmd 	The MsnCommand to be ref.
============================================================
--- libpurple/protocols/msn/directconn.c	05c36653b8d84730e856ec63c550bab888b6e894
+++ libpurple/protocols/msn/directconn.c	d460d3063a183c5462e17fca6884dce66dc0315c
@@ -602,7 +602,7 @@ msn_dc_process_packet(MsnDirectConn *dc,
 		if (dc->header.length) {
 			part = msn_slpmsgpart_new_from_data(dc->in_buffer + 4, dc->header.length);
 			msn_slplink_process_msg(dc->slplink, part);
-			msn_slpmsgpart_destroy(part);
+			msn_slpmsgpart_unref(part);
 		}
 
 		/*
============================================================
--- libpurple/protocols/msn/slplink.c	596fd5e68760fc87b2ade78d44e0d7983e8c3110
+++ libpurple/protocols/msn/slplink.c	8bed55f48b636351b9322177baf07fbdd6a82b6b
@@ -96,18 +96,11 @@ msn_slplink_destroy(MsnSlpLink *slplink)
 	if (purple_debug_is_verbose())
 		purple_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink);
 
-	g_return_if_fail(slplink != NULL);
-
 	if (slplink->swboard != NULL) {
 		slplink->swboard->slplinks = g_list_remove(slplink->swboard->slplinks, slplink);
 		slplink->swboard = NULL;
 	}
 
-	if (slplink->refs > 1) {
-		slplink->refs--;
-		return;
-	}
-
 	session = slplink->session;
 
 	if (slplink->dc != NULL) {
============================================================
--- libpurple/protocols/msn/slpmsg.c	dd02d7630fcfb6d8b5f075fe52fe69823a7c6c3a
+++ libpurple/protocols/msn/slpmsg.c	49bb900b84c8619414ada554c7b2df7f77e27267
@@ -85,7 +85,7 @@ msn_slpmsg_destroy(MsnSlpMessage *slpmsg
 		part->ack_cb = NULL;
 		part->nak_cb = NULL;
 		part->ack_data = NULL;
-		msn_slpmsgpart_destroy(part);
+		msn_slpmsgpart_unref(part);
 	}
 
 	slplink->slp_msgs = g_list_remove(slplink->slp_msgs, slpmsg);
============================================================
--- libpurple/protocols/msn/slpmsg_part.c	1586ca5ced28deee344c74bca8569d9167062e9c
+++ libpurple/protocols/msn/slpmsg_part.c	5172e1f79f702224e71cae2720012dd682b3b116
@@ -81,17 +81,8 @@ MsnSlpMessagePart *msn_slpmsgpart_new_fr
 	return part;
 }
 
-void msn_slpmsgpart_destroy(MsnSlpMessagePart *part)
+static void msn_slpmsgpart_destroy(MsnSlpMessagePart *part)
 {
-	if (!part)
-		return;
-
-	if (part->ref_count > 0) {
-		msn_slpmsgpart_unref(part);
-		
-		return;
-	}
-
 	g_free(part->header);
 	g_free(part->footer);
 
============================================================
--- libpurple/protocols/msn/slpmsg_part.h	8ecf00891a53f9c4ff4aff3fe99dafbd4b53beb1
+++ libpurple/protocols/msn/slpmsg_part.h	6603f183b3e056fc2be326062b07f8a10a7cf079
@@ -49,8 +49,6 @@ MsnSlpMessagePart *msn_slpmsgpart_new_fr
 
 MsnSlpMessagePart *msn_slpmsgpart_new_from_data(const char *data, size_t data_len);
 
-void msn_slpmsgpart_destroy(MsnSlpMessagePart *part);
-
 MsnSlpMessagePart *msn_slpmsgpart_ref(MsnSlpMessagePart *part);
 
 void msn_slpmsgpart_unref(MsnSlpMessagePart *part);


More information about the Commits mailing list