Mercurial > pidgin
comparison libpurple/protocols/myspace/message.c @ 19254:9245404fe70c
In msim_msg_get(), start at the given node instead of using g_list_first()
to back track and find the first node (since GList's are doubly-linked, it
can do this).
This means that msim_msg_get_*() functions now return values beginning from
the MsimMessage * that was passed to the function, instead of at the very
beginning, so you can pass an MsimMessage pointer in the middle of an
MsimMessage (which is really just a GList) and it will search starting from
where you gave it.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 19 Aug 2007 23:43:48 +0000 |
parents | b66c5991c011 |
children | 1ea47b06f1a6 |
comparison
equal
deleted
inserted
replaced
19253:b66c5991c011 | 19254:9245404fe70c |
---|---|
1001 * | 1001 * |
1002 */ | 1002 */ |
1003 static GList * | 1003 static GList * |
1004 msim_msg_get_node(MsimMessage *msg, const gchar *name) | 1004 msim_msg_get_node(MsimMessage *msg, const gchar *name) |
1005 { | 1005 { |
1006 GList *i; | 1006 GList *node; |
1007 | 1007 |
1008 if (!name) { | 1008 if (!name) { |
1009 return NULL; | 1009 return NULL; |
1010 } | 1010 } |
1011 | 1011 |
1012 /* Linear search for the given name. O(n) but n is small. */ | 1012 /* Linear search for the given name. O(n) but n is small. */ |
1013 for (i = g_list_first(msg); i != NULL; i = g_list_next(i)) { | 1013 for (node = msg; node != NULL; node = g_list_next(node)) { |
1014 MsimMessageElement *elem; | 1014 MsimMessageElement *elem; |
1015 | 1015 |
1016 elem = i->data; | 1016 elem = node->data; |
1017 g_return_val_if_fail(elem != NULL, NULL); | 1017 g_return_val_if_fail(elem != NULL, NULL); |
1018 | 1018 |
1019 if (strcmp(elem->name, name) == 0) { | 1019 if (strcmp(elem->name, name) == 0) { |
1020 return i; | 1020 return node; |
1021 } | 1021 } |
1022 } | 1022 } |
1023 return NULL; | 1023 return NULL; |
1024 } | 1024 } |
1025 | 1025 |