Changeset e849734 for message.c


Ignore:
Timestamp:
Feb 28, 2007, 9:07:37 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
50622a5
Parents:
e7dc035
git-author:
Nelson Elhage <nelhage@mit.edu> (02/27/07 23:59:11)
git-committer:
Nelson Elhage <nelhage@mit.edu> (02/28/07 21:07:37)
Message:
Intern hostnames and message attribute keys
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    re363375 re849734  
    3939{
    4040  int i, j;
    41   owl_pair *p;
    42 
    43   /* look for an existing pair with this key, and nuke the entry if
    44      found */
     41  owl_pair *p = NULL, *pair = NULL;
     42
     43  /* look for an existing pair with this key, */
    4544  j=owl_list_get_size(&(m->attributes));
    4645  for (i=0; i<j; i++) {
    4746    p=owl_list_get_element(&(m->attributes), i);
    4847    if (!strcmp(owl_pair_get_key(p), attrname)) {
    49       owl_free(owl_pair_get_key(p));
    5048      owl_free(owl_pair_get_value(p));
    51       owl_free(p);
    52       owl_list_remove_element(&(m->attributes), i);
     49      pair = p;
    5350      break;
    5451    }
    5552  }
    5653
    57   p=owl_malloc(sizeof(owl_pair));
    58   owl_pair_create(p, owl_strdup(attrname), owl_strdup(attrvalue));
    59   owl_list_append_element(&(m->attributes), p);
     54  if(pair ==  NULL) {
     55    pair = owl_malloc(sizeof(owl_pair));
     56    owl_pair_create(pair, owl_global_intern(&g, attrname), NULL);
     57    owl_list_append_element(&(m->attributes), pair);
     58  }
     59  owl_pair_set_value(pair, owl_strdup(attrvalue));
    6060}
    6161
     
    483483void owl_message_set_hostname(owl_message *m, char *hostname)
    484484{
    485   if (m==NULL) return;
    486   if (m->hostname!=NULL) {
    487     owl_free(m->hostname);
    488   }
    489   m->hostname=owl_strdup(hostname);
     485  m->hostname=owl_global_intern(&g, hostname);
    490486}
    491487
Note: See TracChangeset for help on using the changeset viewer.