pidgin: b70000f3: Mark some parameters as const char * ins...

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Dec 15 20:45:52 EST 2008


-----------------------------------------------------------------
Revision: b70000f3bf5c6b7f30121fb749d72ac869b58ae9
Ancestor: fee55d3168b65006229ddb510d2882e6bffbf1cd
Author: markdoliner at pidgin.im
Date: 2008-12-16T01:40:38
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/b70000f3bf5c6b7f30121fb749d72ac869b58ae9

Modified files:
        libpurple/protocols/myspace/message.c
        libpurple/protocols/myspace/message.h
        libpurple/protocols/myspace/myspace.c

ChangeLog: 

Mark some parameters as const char * instead of char * and don't
needlessly strdup

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/message.c	7d7fdff0b78e691b09d9fe9c7e347ba8565bd297
+++ libpurple/protocols/myspace/message.c	0cfccdf0960db2dd55ddf6d9b9b290af6b994749
@@ -1005,7 +1005,7 @@ MsimMessage *
  * @return MsimMessage *. Caller should msim_msg_free() when done.
  */
 MsimMessage *
-msim_parse(gchar *raw)
+msim_parse(const gchar *raw)
 {
 	MsimMessage *msg;
 	gchar *token;
@@ -1026,7 +1026,6 @@ msim_parse(gchar *raw)
 				"missing initial backslash: <%s>\n", raw);
 		/* XXX: Should we try to recover, and read to first backslash? */
 
-		g_free(raw);
 		return NULL;
 	}
 
@@ -1057,9 +1056,6 @@ msim_parse(gchar *raw)
 	}
 	g_strfreev(tokens);
 
-	/* Can free now since all data was copied to hash key/values */
-	g_free(raw);
-
 	return msg;
 }
 
@@ -1214,8 +1210,8 @@ msim_msg_get_list(MsimMessage *msg, cons
  *
  * @return A new MsimMessage *. Must msim_msg_free() when done.
  */
-MsimMessage *
-msim_msg_dictionary_parse(gchar *raw)
+static MsimMessage *
+msim_msg_dictionary_parse(const gchar *raw)
 {
 	MsimMessage *dict;
 	gchar *item;
@@ -1275,7 +1271,7 @@ msim_msg_get_dictionary_from_element(Msi
 			return msim_msg_clone((MsimMessage *)elem->data);
 
 		case MSIM_TYPE_RAW:
-			return msim_msg_dictionary_parse((gchar *)elem->data);
+			return msim_msg_dictionary_parse(elem->data);
 
 		default:
 			purple_debug_info("msim_msg_get_dictionary", "type %d unknown, name %s\n",
============================================================
--- libpurple/protocols/myspace/message.h	2c57b672930e02bcb478208cfc6bf59dfb1c419e
+++ libpurple/protocols/myspace/message.h	661cb0c755874fa95db72bc7a29bd37e9ce78c07
@@ -91,8 +91,7 @@ gboolean msim_msg_send(struct _MsimSessi
 
 gboolean msim_msg_send(struct _MsimSession *session, MsimMessage *msg);
 
-MsimMessage *msim_parse(gchar *raw);
-MsimMessage *msim_msg_dictionary_parse(gchar *raw);
+MsimMessage *msim_parse(const gchar *raw);
 
 MsimMessageElement *msim_msg_get(MsimMessage *msg, const gchar *name);
 
============================================================
--- libpurple/protocols/myspace/myspace.c	cf98578d19f7b7c86eff33653ff276b8108a7141
+++ libpurple/protocols/myspace/myspace.c	6ad9d696de3bd60e5668bf40d2600cf25c00a528
@@ -2598,7 +2598,7 @@ msim_input_cb(gpointer gc_uncasted, gint
 		purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf);
 #endif
 		*end = 0;
-		msg = msim_parse(g_strdup(session->rxbuf));
+		msg = msim_parse(session->rxbuf);
 		if (!msg) {
 			purple_debug_info("msim", "msim_input_cb: couldn't parse rxbuf\n");
 			purple_connection_error_reason (gc,


More information about the Commits mailing list