Changeset f9df2f0


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:
e4d7cb6
Parents:
fc8a87a
git-author:
David Benjamin <davidben@mit.edu> (03/10/11 14:57:25)
git-committer:
David Benjamin <davidben@mit.edu> (06/25/11 03:26:15)
Message:
Replace owl_message's owl_list with a GPtrArray
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r6829afc rf9df2f0  
    4343
    4444  owl_message_set_hostname(m, "");
    45   owl_list_create(&(m->attributes));
     45  m->attributes = g_ptr_array_new();
    4646 
    4747  /* save the time */
     
    5858void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue)
    5959{
    60   int i, j;
     60  int i;
    6161  owl_pair *p = NULL, *pair = NULL;
    6262
     
    6464
    6565  /* look for an existing pair with this key, */
    66   j=owl_list_get_size(&(m->attributes));
    67   for (i=0; i<j; i++) {
    68     p=owl_list_get_element(&(m->attributes), i);
     66  for (i = 0; i < m->attributes->len; i++) {
     67    p = m->attributes->pdata[i];
    6968    if (owl_pair_get_key(p) == attrname) {
    7069      g_free(owl_pair_get_value(p));
     
    7776    pair = g_new(owl_pair, 1);
    7877    owl_pair_create(pair, attrname, NULL);
    79     owl_list_append_element(&(m->attributes), pair);
     78    g_ptr_array_add(m->attributes, pair);
    8079  }
    8180  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
     
    8786const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname)
    8887{
    89   int i, j;
     88  int i;
    9089  owl_pair *p;
    9190  GQuark quark;
     
    9796  attrname = g_quark_to_string(quark);
    9897
    99   j=owl_list_get_size(&(m->attributes));
    100   for (i=0; i<j; i++) {
    101     p=owl_list_get_element(&(m->attributes), i);
     98  for (i = 0; i < m->attributes->len; i++) {
     99    p = m->attributes->pdata[i];
    102100    if (owl_pair_get_key(p) == attrname) {
    103101      return(owl_pair_get_value(p));
     
    118116 */
    119117void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) {
    120   int i, j;
     118  int i;
    121119  owl_pair *p;
    122120  char *buff, *tmpbuff;
     
    124122  owl_fmtext_init_null(fm);
    125123
    126   j=owl_list_get_size(&(m->attributes));
    127   for (i=0; i<j; i++) {
    128     p=owl_list_get_element(&(m->attributes), i);
     124  for (i = 0; i < m->attributes->len; i++) {
     125    p = m->attributes->pdata[i];
    129126
    130127    tmpbuff = g_strdup(owl_pair_get_value(p));
     
    10041001void owl_message_cleanup(owl_message *m)
    10051002{
    1006   int i, j;
     1003  int i;
    10071004  owl_pair *p;
    10081005#ifdef HAVE_LIBZEPHYR   
     
    10141011
    10151012  /* free all the attributes */
    1016   j=owl_list_get_size(&(m->attributes));
    1017   for (i=0; i<j; i++) {
    1018     p=owl_list_get_element(&(m->attributes), i);
     1013  for (i = 0; i < m->attributes->len; i++) {
     1014    p = m->attributes->pdata[i];
    10191015    g_free(owl_pair_get_value(p));
    10201016    g_free(p);
    10211017  }
    10221018
    1023   owl_list_cleanup(&(m->attributes), NULL);
     1019  g_ptr_array_free(m->attributes, true);
    10241020 
    10251021  owl_message_invalidate_format(m);
  • owl.h

    rfc8a87a rf9df2f0  
    363363  int delete;
    364364  const char *hostname;
    365   owl_list attributes;            /* this is a list of pairs */
     365  GPtrArray *attributes;          /* this is a list of pairs */
    366366  char *timestr;
    367367  time_t time;
  • perlconfig.c

    r6829afc rf9df2f0  
    115115  }
    116116
    117   j=owl_list_get_size(&(m->attributes));
    118   for(i=0; i<j; i++) {
    119     pair=owl_list_get_element(&(m->attributes), i);
     117  for (i = 0; i < m->attributes->len; i++) {
     118    pair = m->attributes->pdata[i];
    120119    (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    121120                   owl_new_sv(owl_pair_get_value(pair)),0);
Note: See TracChangeset for help on using the changeset viewer.