Changeset d191f45
- Timestamp:
- Jun 25, 2011, 3:26:15 AM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 7ed9bc6
- Parents:
- e4d7cb6
- git-author:
- David Benjamin <davidben@mit.edu> (03/11/11 11:10:36)
- git-committer:
- David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
buddylist.c
r96828e4 rd191f45 3 3 void owl_buddylist_init(owl_buddylist *bl) 4 4 { 5 owl_list_create(&(bl->buddies));5 bl->buddies = g_ptr_array_new(); 6 6 } 7 7 … … 14 14 15 15 owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname); 16 owl_list_append_element(&(bl->buddies), b);16 g_ptr_array_add(bl->buddies, b); 17 17 } 18 18 … … 21 21 int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, const char *name) 22 22 { 23 int i , j;23 int i; 24 24 owl_buddy *b; 25 25 26 j=owl_list_get_size(&(bl->buddies)); 27 for (i=0; i<j; i++) { 28 b=owl_list_get_element(&(bl->buddies), i); 26 for (i = 0; i < bl->buddies->len; i++) { 27 b = bl->buddies->pdata[i]; 29 28 if (!strcasecmp(name, owl_buddy_get_name(b)) && owl_buddy_is_proto_aim(b)) { 30 owl_list_remove_element(&(bl->buddies), i); 31 owl_buddy_delete(b); 29 owl_buddy_delete(g_ptr_array_remove_index(bl->buddies, i)); 32 30 return(0); 33 31 } … … 87 85 int owl_buddylist_get_size(const owl_buddylist *bl) 88 86 { 89 return (owl_list_get_size(&(bl->buddies)));87 return bl->buddies->len; 90 88 } 91 89 … … 97 95 if (index>(owl_buddylist_get_size(bl)-1)) return(NULL); 98 96 99 return (owl_list_get_element(&(bl->buddies), index));97 return bl->buddies->pdata[index]; 100 98 } 101 99 … … 105 103 owl_buddy *owl_buddylist_get_aim_buddy(const owl_buddylist *bl, const char *name) 106 104 { 107 int i , j;105 int i; 108 106 owl_buddy *b; 109 107 110 j=owl_list_get_size(&(bl->buddies)); 111 for (i=0; i<j; i++) { 112 b=owl_list_get_element(&(bl->buddies), i); 108 for (i = 0; i < bl->buddies->len; i++) { 109 b = bl->buddies->pdata[i]; 113 110 if (!strcasecmp(name, owl_buddy_get_name(b))) return(b); 114 111 } … … 131 128 void owl_buddylist_clear(owl_buddylist *bl) 132 129 { 133 owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);134 owl_list_create(&(bl->buddies));130 g_ptr_array_foreach(bl->buddies, (GFunc)owl_buddy_delete, NULL); 131 g_ptr_array_set_size(bl->buddies, 0); 135 132 } 136 133 137 134 void owl_buddylist_cleanup(owl_buddylist *bl) 138 135 { 139 owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete); 136 g_ptr_array_foreach(bl->buddies, (GFunc)owl_buddy_delete, NULL); 137 g_ptr_array_free(bl->buddies, true); 140 138 } -
owl.h
re4d7cb6 rd191f45 508 508 509 509 typedef struct _owl_buddylist { 510 owl_listbuddies;510 GPtrArray *buddies; 511 511 } owl_buddylist; 512 512
Note: See TracChangeset
for help on using the changeset viewer.