Changeset d191f45


Ignore:
Timestamp:
Jun 25, 2011, 3:26:15 AM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
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)
Message:
Make owl_buddylist use a GPtrArray directly
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • buddylist.c

    r96828e4 rd191f45  
    33void owl_buddylist_init(owl_buddylist *bl)
    44{
    5   owl_list_create(&(bl->buddies));
     5  bl->buddies = g_ptr_array_new();
    66}
    77
     
    1414 
    1515  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
    16   owl_list_append_element(&(bl->buddies), b);
     16  g_ptr_array_add(bl->buddies, b);
    1717}
    1818
     
    2121int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, const char *name)
    2222{
    23   int i, j;
     23  int i;
    2424  owl_buddy *b;
    2525
    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];
    2928    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));
    3230      return(0);
    3331    }
     
    8785int owl_buddylist_get_size(const owl_buddylist *bl)
    8886{
    89   return(owl_list_get_size(&(bl->buddies)));
     87  return bl->buddies->len;
    9088}
    9189
     
    9795  if (index>(owl_buddylist_get_size(bl)-1)) return(NULL);
    9896
    99   return(owl_list_get_element(&(bl->buddies), index));
     97  return bl->buddies->pdata[index];
    10098}
    10199
     
    105103owl_buddy *owl_buddylist_get_aim_buddy(const owl_buddylist *bl, const char *name)
    106104{
    107   int i, j;
     105  int i;
    108106  owl_buddy *b;
    109107
    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];
    113110    if (!strcasecmp(name, owl_buddy_get_name(b))) return(b);
    114111  }
     
    131128void owl_buddylist_clear(owl_buddylist *bl)
    132129{
    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);
    135132}
    136133
    137134void owl_buddylist_cleanup(owl_buddylist *bl)
    138135{
    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);
    140138}
  • owl.h

    re4d7cb6 rd191f45  
    508508
    509509typedef struct _owl_buddylist {
    510   owl_list buddies;
     510  GPtrArray *buddies;
    511511} owl_buddylist;
    512512
Note: See TracChangeset for help on using the changeset viewer.