Changeset 7dcef03 for filter.c


Ignore:
Timestamp:
Dec 25, 2013, 11:33:37 AM (8 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master
Children:
8f95fc4, db1a2f8b, c53f5e8, 1bd5aa9
Parents:
d779a1a
git-author:
Anders Kaseorg <andersk@mit.edu> (12/25/13 11:18:38)
git-committer:
Anders Kaseorg <andersk@mit.edu> (12/25/13 11:33:37)
Message:
Use the Glib slice allocator for fixed-size objects

The slice allocator, available since GLib 2.10, is more
space-efficient than [g_]malloc.  Since BarnOwl is obviously at the
leading edge of space-efficient technology, this seems like a natural
fit.  Use it for every fixed-size object except
owl_viewwin_search_data (which would need an extra destroy_cbdata
function to g_slice_free it).

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

Legend:

Unmodified
Added
Removed
  • filter.c

    rc068c03 r7dcef03  
    1818  owl_filter *f;
    1919
    20   f = g_new(owl_filter, 1);
     20  f = g_slice_new(owl_filter);
    2121
    2222  f->name=g_strdup(name);
     
    6969  if(!argc) return NULL;
    7070
    71   fe = g_new(owl_filterelement, 1);
     71  fe = g_slice_new(owl_filterelement);
    7272  owl_filterelement_create(fe);
    7373
     
    114114err:
    115115  owl_filterelement_cleanup(fe);
    116   g_free(fe);
     116  g_slice_free(owl_filterelement, fe);
    117117  return NULL;
    118118}
     
    132132    op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip);
    133133    if(!op2) goto err;
    134     tmp = g_new(owl_filterelement, 1);
     134    tmp = g_slice_new(owl_filterelement);
    135135    if(!strcasecmp(argv[i], "and")) {
    136136      owl_filterelement_create_and(tmp, op1, op2);
     
    152152  if(op1) {
    153153    owl_filterelement_cleanup(op1);
    154     g_free(op1);
     154    g_slice_free(owl_filterelement, op1);
    155155  }
    156156  return NULL;
     
    262262  if (f->root) {
    263263    owl_filterelement_cleanup(f->root);
    264     g_free(f->root);
     264    g_slice_free(owl_filterelement, f->root);
    265265  }
    266266  if (f->name)
    267267    g_free(f->name);
    268   g_free(f);
    269 }
     268  g_slice_free(owl_filter, f);
     269}
Note: See TracChangeset for help on using the changeset viewer.