Changeset 6a5f0c3 for perlconfig.c


Ignore:
Timestamp:
Dec 25, 2013, 3:22:29 PM (10 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Children:
b36b9a6
Parents:
58777e9
git-author:
Anders Kaseorg <andersk@mit.edu> (12/25/13 12:53:27)
git-committer:
Anders Kaseorg <andersk@mit.edu> (12/25/13 15:22:29)
Message:
owl_message_set_attribute: Take a destroy function for the value

In the case of constant strings, and ZNotice_t fields other than the
body, this lets us avoid wasting memory on unnecessary string copies.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    r8f95fc4 r6a5f0c3  
    195195    key = hv_iterkey(ent, &len);
    196196    val = SvPV_nolen(hv_iterval(hash, ent));
    197     if(!strcmp(key, "type")) {
    198       owl_message_set_type(m, val);
    199     } else if(!strcmp(key, "direction")) {
     197    if (!strcmp(key, "direction")) {
    200198      owl_message_set_direction(m, owl_message_parse_direction(val));
    201199    } else if(!strcmp(key, "private")) {
     
    206204    } else if (!strcmp(key, "hostname")) {
    207205      owl_message_set_hostname(m, val);
    208     } else if (!strcmp(key, "zwriteline")) {
    209       owl_message_set_zwriteline(m, val);
    210206    } else if (!strcmp(key, "time")) {
    211207      g_free(m->timestr);
     
    214210      m->time = mktime(&tm);
    215211    } else {
    216       owl_message_set_attribute(m, key, val);
     212      owl_message_set_attribute(m, key, g_strdup(val), g_free);
    217213    }
    218214  }
    219215  if(owl_message_is_type_admin(m)) {
    220216    if(!owl_message_get_attribute_value(m, "adminheader"))
    221       owl_message_set_attribute(m, "adminheader", "");
     217      owl_message_set_attribute(m, "adminheader", "", NULL);
    222218  }
    223219  return m;
Note: See TracChangeset for help on using the changeset viewer.