[514] in BarnOwl Developers
[D-O-H] r634 - in trunk: . owl
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:06:58 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 28 Feb 2007 21:07:37 -0500 (EST)
Author: nelhage
Date: 2007-02-28 21:07:37 -0500 (Wed, 28 Feb 2007)
New Revision: 634
Modified:
trunk/
trunk/owl/message.c
Log:
r19149@phanatique: nelhage | 2007-02-27 23:59:11 -0500
Intern hostnames and message attribute keys
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:19148
+ bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:19149
Modified: trunk/owl/message.c
===================================================================
--- trunk/owl/message.c 2007-03-01 02:07:32 UTC (rev 633)
+++ trunk/owl/message.c 2007-03-01 02:07:37 UTC (rev 634)
@@ -38,25 +38,25 @@
void owl_message_set_attribute(owl_message *m, char *attrname, char *attrvalue)
{
int i, j;
- owl_pair *p;
+ owl_pair *p = NULL, *pair = NULL;
- /* look for an existing pair with this key, and nuke the entry if
- found */
+ /* look for an existing pair with this key, */
j=owl_list_get_size(&(m->attributes));
for (i=0; i<j; i++) {
p=owl_list_get_element(&(m->attributes), i);
if (!strcmp(owl_pair_get_key(p), attrname)) {
- owl_free(owl_pair_get_key(p));
owl_free(owl_pair_get_value(p));
- owl_free(p);
- owl_list_remove_element(&(m->attributes), i);
+ pair = p;
break;
}
}
- p=owl_malloc(sizeof(owl_pair));
- owl_pair_create(p, owl_strdup(attrname), owl_strdup(attrvalue));
- owl_list_append_element(&(m->attributes), p);
+ if(pair == NULL) {
+ pair = owl_malloc(sizeof(owl_pair));
+ owl_pair_create(pair, owl_global_intern(&g, attrname), NULL);
+ owl_list_append_element(&(m->attributes), pair);
+ }
+ owl_pair_set_value(pair, owl_strdup(attrvalue));
}
/* return the value associated with the named attribute, or NULL if
@@ -482,11 +482,7 @@
void owl_message_set_hostname(owl_message *m, char *hostname)
{
- if (m==NULL) return;
- if (m->hostname!=NULL) {
- owl_free(m->hostname);
- }
- m->hostname=owl_strdup(hostname);
+ m->hostname=owl_global_intern(&g, hostname);
}
char *owl_message_get_hostname(owl_message *m)