changeset 30952:b4285ea42b6e

msn_message_destroy() calls msn_message_unref() if refcount>0. This is always the case. So change all code to call msn_message_unref() directly and change msn_message_destroy to be a private function. This should be more clear.
author Mark Doliner <mark@kingant.net>
date Mon, 22 Nov 2010 07:40:23 +0000
parents a328691c761a
children 5eb2ea662d8c
files libpurple/protocols/msn/msg.c libpurple/protocols/msn/msg.h libpurple/protocols/msn/msn.c libpurple/protocols/msn/notification.c libpurple/protocols/msn/oim.c libpurple/protocols/msn/sbconn.c libpurple/protocols/msn/switchboard.c
diffstat 7 files changed, 20 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/msg.c	Mon Nov 22 07:40:23 2010 +0000
@@ -50,18 +50,16 @@
 	return msg;
 }
 
-void
+/**
+ * Destroys a message.
+ *
+ * @param msg The message to destroy.
+ */
+static void
 msn_message_destroy(MsnMessage *msg)
 {
 	g_return_if_fail(msg != NULL);
 
-	if (msg->ref_count > 0)
-	{
-		msn_message_unref(msg);
-
-		return;
-	}
-
 	if (purple_debug_is_verbose())
 		purple_debug_info("msn", "message destroy (%p)\n", msg);
 
@@ -1224,7 +1222,7 @@
 			g_free(text);
 
 			msn_switchboard_send_msg(swboard, cancel, TRUE);
-			msn_message_destroy(cancel);
+			msn_message_unref(cancel);
 		}
 
 	} else if (!strcmp(command, "CANCEL")) {
--- a/libpurple/protocols/msn/msg.h	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/msg.h	Mon Nov 22 07:40:23 2010 +0000
@@ -171,13 +171,6 @@
 						  const char *line_dem,const char *body_dem);
 
 /**
- * Destroys a message.
- *
- * @param msg The message to destroy.
- */
-void msn_message_destroy(MsnMessage *msg);
-
-/**
  * Increments the reference count on a message.
  *
  * @param msg The message.
--- a/libpurple/protocols/msn/msn.c	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/msn.c	Mon Nov 22 07:40:23 2010 +0000
@@ -132,7 +132,7 @@
 	swboard = msn_session_get_swboard(session, username, MSN_SB_FLAG_IM);
 
 	msn_switchboard_send_msg(swboard, msg, TRUE);
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 
 	return TRUE;
 }
@@ -1393,7 +1393,7 @@
 	msn_message_set_bin_data(msg, body->str, body->len);
 
 	msn_switchboard_send_msg(swboard, msg, TRUE);
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 }
 
 static void msn_emoticon_destroy(MsnEmoticon *emoticon)
@@ -1582,7 +1582,7 @@
 			purple_timeout_add(0, msn_send_me_im, imdata);
 		}
 
-		msn_message_destroy(msg);
+		msn_message_unref(msg);
 	} else {
 		/*send Offline Instant Message,only to MSN Passport User*/
 		char *friendname;
@@ -1646,7 +1646,7 @@
 
 	msn_switchboard_send_msg(swboard, msg, FALSE);
 
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 
 	return MSN_TYPING_SEND_TIMEOUT;
 }
@@ -2072,7 +2072,7 @@
 	}
 
 	msn_switchboard_send_msg(swboard, msg, FALSE);
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 
 	g_free(msgformat);
 	g_free(msgtext);
--- a/libpurple/protocols/msn/notification.c	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/notification.c	Mon Nov 22 07:40:23 2010 +0000
@@ -332,7 +332,7 @@
 
 	msn_cmdproc_process_msg(cmdproc, msg);
 
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 }
 
 static void
@@ -1210,7 +1210,7 @@
 
 					g_free(body_str);
 					g_free(body_enc);
-					msn_message_destroy(msg);
+					msn_message_unref(msg);
 					trans->data = NULL;
 				}
 			}
--- a/libpurple/protocols/msn/oim.c	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/oim.c	Mon Nov 22 07:40:23 2010 +0000
@@ -641,10 +641,10 @@
 			type = msn_message_get_content_type(multipart);
 			if (type && !strcmp(type, "text/plain")) {
 				decode_msg = (char *)purple_base64_decode(multipart->body, &body_len);
-				msn_message_destroy(multipart);
+				msn_message_unref(multipart);
 				break;
 			}
-			msn_message_destroy(multipart);
+			msn_message_unref(multipart);
 		}
 
 		g_strfreev(tokens);
@@ -652,7 +652,7 @@
 
 		if (decode_msg == NULL) {
 			purple_debug_error("msn", "Couldn't find text/plain OIM message.\n");
-			msn_message_destroy(message);
+			msn_message_unref(message);
 			return;
 		}
 	} else {
@@ -708,7 +708,7 @@
 
 	g_free(passport);
 	g_free(decode_msg);
-	msn_message_destroy(message);
+	msn_message_unref(message);
 }
 
 /* Parse the XML data,
--- a/libpurple/protocols/msn/sbconn.c	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/sbconn.c	Mon Nov 22 07:40:23 2010 +0000
@@ -33,7 +33,7 @@
 	}
 
 	msn_switchboard_send_msg(slplink->swboard, msg, TRUE);
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 }
 
 /** Called when a message times out. */
--- a/libpurple/protocols/msn/switchboard.c	Mon Nov 22 07:32:57 2010 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Mon Nov 22 07:40:23 2010 +0000
@@ -225,7 +225,7 @@
 
 	msn_switchboard_send_msg(swboard, msg, TRUE);
 
-	msn_message_destroy(msg);
+	msn_message_unref(msg);
 }
 
 static void