changeset 24728:c1c464583f8c

Mark some parameters as const char * instead of char * and don't needlessly strdup
author Mark Doliner <mark@kingant.net>
date Tue, 16 Dec 2008 01:40:38 +0000
parents 3f4bf7c43df4
children ce108a92fa4e
files libpurple/protocols/myspace/message.c libpurple/protocols/myspace/message.h libpurple/protocols/myspace/myspace.c
diffstat 3 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c	Tue Dec 16 01:03:24 2008 +0000
+++ b/libpurple/protocols/myspace/message.c	Tue Dec 16 01:40:38 2008 +0000
@@ -1005,7 +1005,7 @@
  * @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 @@
 				"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 @@
 	}
 	g_strfreev(tokens);
 
-	/* Can free now since all data was copied to hash key/values */
-	g_free(raw);
-
 	return msg;
 }
 
@@ -1214,8 +1210,8 @@
  *
  * @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 @@
 			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",
--- a/libpurple/protocols/myspace/message.h	Tue Dec 16 01:03:24 2008 +0000
+++ b/libpurple/protocols/myspace/message.h	Tue Dec 16 01:40:38 2008 +0000
@@ -91,8 +91,7 @@
 
 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);
 
--- a/libpurple/protocols/myspace/myspace.c	Tue Dec 16 01:03:24 2008 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Tue Dec 16 01:40:38 2008 +0000
@@ -2598,7 +2598,7 @@
 		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,