comparison libpurple/protocols/bonjour/buddy.c @ 19573:affacee881e8

Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times. Thanks to Lennart from the Avahi team for suggestions on how to improve the avahi implementation.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 02 Sep 2007 17:54:44 +0000
parents 2d6d936867bc
children 44b4e8bd759b
comparison
equal deleted inserted replaced
19572:cfc4e56a6a1e 19573:affacee881e8
119 * If the buddy does not yet exist, then create it and add it to 119 * If the buddy does not yet exist, then create it and add it to
120 * our buddy list. In either case we set the correct status for 120 * our buddy list. In either case we set the correct status for
121 * the buddy. 121 * the buddy.
122 */ 122 */
123 void 123 void
124 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy) 124 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy)
125 { 125 {
126 PurpleBuddy *buddy;
127 PurpleGroup *group; 126 PurpleGroup *group;
128 PurpleAccount *account = bonjour_buddy->account; 127 PurpleAccount *account = bonjour_buddy->account;
129 const char *status_id, *old_hash, *new_hash; 128 const char *status_id, *old_hash, *new_hash;
130 129
131 /* Translate between the Bonjour status and the Purple status */ 130 /* Translate between the Bonjour status and the Purple status */
145 group = purple_group_new(BONJOUR_GROUP_NAME); 144 group = purple_group_new(BONJOUR_GROUP_NAME);
146 purple_blist_add_group(group, NULL); 145 purple_blist_add_group(group, NULL);
147 } 146 }
148 147
149 /* Make sure the buddy exists in our buddy list */ 148 /* Make sure the buddy exists in our buddy list */
150 buddy = purple_find_buddy(account, bonjour_buddy->name); 149 if (buddy == NULL)
150 buddy = purple_find_buddy(account, bonjour_buddy->name);
151 151
152 if (buddy == NULL) { 152 if (buddy == NULL) {
153 buddy = purple_buddy_new(account, bonjour_buddy->name, NULL); 153 buddy = purple_buddy_new(account, bonjour_buddy->name, NULL);
154 buddy->proto_data = bonjour_buddy; 154 buddy->proto_data = bonjour_buddy;
155 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE); 155 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE);