Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/message.c @ 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 | 68cc1a8a0d21 |
children | 5f8e8b89b143 |
comparison
equal
deleted
inserted
replaced
24727:3f4bf7c43df4 | 24728:c1c464583f8c |
---|---|
1003 * @param raw The raw message string to parse, will be g_free()'d. | 1003 * @param raw The raw message string to parse, will be g_free()'d. |
1004 * | 1004 * |
1005 * @return MsimMessage *. Caller should msim_msg_free() when done. | 1005 * @return MsimMessage *. Caller should msim_msg_free() when done. |
1006 */ | 1006 */ |
1007 MsimMessage * | 1007 MsimMessage * |
1008 msim_parse(gchar *raw) | 1008 msim_parse(const gchar *raw) |
1009 { | 1009 { |
1010 MsimMessage *msg; | 1010 MsimMessage *msg; |
1011 gchar *token; | 1011 gchar *token; |
1012 gchar **tokens; | 1012 gchar **tokens; |
1013 gchar *key; | 1013 gchar *key; |
1024 if (raw[0] != '\\' || raw[1] == 0) { | 1024 if (raw[0] != '\\' || raw[1] == 0) { |
1025 purple_debug_info("msim", "msim_parse: incomplete/bad string, " | 1025 purple_debug_info("msim", "msim_parse: incomplete/bad string, " |
1026 "missing initial backslash: <%s>\n", raw); | 1026 "missing initial backslash: <%s>\n", raw); |
1027 /* XXX: Should we try to recover, and read to first backslash? */ | 1027 /* XXX: Should we try to recover, and read to first backslash? */ |
1028 | 1028 |
1029 g_free(raw); | |
1030 return NULL; | 1029 return NULL; |
1031 } | 1030 } |
1032 | 1031 |
1033 msg = msim_msg_new(FALSE); | 1032 msg = msim_msg_new(FALSE); |
1034 | 1033 |
1055 key = token; | 1054 key = token; |
1056 } | 1055 } |
1057 } | 1056 } |
1058 g_strfreev(tokens); | 1057 g_strfreev(tokens); |
1059 | 1058 |
1060 /* Can free now since all data was copied to hash key/values */ | |
1061 g_free(raw); | |
1062 | |
1063 return msg; | 1059 return msg; |
1064 } | 1060 } |
1065 | 1061 |
1066 /** | 1062 /** |
1067 * Return the first MsimMessageElement * with given name in the MsimMessage *. | 1063 * Return the first MsimMessageElement * with given name in the MsimMessage *. |
1212 * @param raw The text of the dictionary to parse. Often the | 1208 * @param raw The text of the dictionary to parse. Often the |
1213 * value for the 'body' field. | 1209 * value for the 'body' field. |
1214 * | 1210 * |
1215 * @return A new MsimMessage *. Must msim_msg_free() when done. | 1211 * @return A new MsimMessage *. Must msim_msg_free() when done. |
1216 */ | 1212 */ |
1217 MsimMessage * | 1213 static MsimMessage * |
1218 msim_msg_dictionary_parse(gchar *raw) | 1214 msim_msg_dictionary_parse(const gchar *raw) |
1219 { | 1215 { |
1220 MsimMessage *dict; | 1216 MsimMessage *dict; |
1221 gchar *item; | 1217 gchar *item; |
1222 gchar **items; | 1218 gchar **items; |
1223 gchar **elements; | 1219 gchar **elements; |
1273 switch (elem->type) { | 1269 switch (elem->type) { |
1274 case MSIM_TYPE_DICTIONARY: | 1270 case MSIM_TYPE_DICTIONARY: |
1275 return msim_msg_clone((MsimMessage *)elem->data); | 1271 return msim_msg_clone((MsimMessage *)elem->data); |
1276 | 1272 |
1277 case MSIM_TYPE_RAW: | 1273 case MSIM_TYPE_RAW: |
1278 return msim_msg_dictionary_parse((gchar *)elem->data); | 1274 return msim_msg_dictionary_parse(elem->data); |
1279 | 1275 |
1280 default: | 1276 default: |
1281 purple_debug_info("msim_msg_get_dictionary", "type %d unknown, name %s\n", | 1277 purple_debug_info("msim_msg_get_dictionary", "type %d unknown, name %s\n", |
1282 elem->type, elem->name ? elem->name : "(NULL)"); | 1278 elem->type, elem->name ? elem->name : "(NULL)"); |
1283 return NULL; | 1279 return NULL; |