Changeset 7dcef03 for zwrite.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
  • zwrite.c

    r919cbf2 r7dcef03  
    33CALLER_OWN owl_zwrite *owl_zwrite_new_from_line(const char *line)
    44{
    5   owl_zwrite *z = g_new(owl_zwrite, 1);
     5  owl_zwrite *z = g_slice_new(owl_zwrite);
    66  if (owl_zwrite_create_from_line(z, line) != 0) {
    7     g_free(z);
     7    g_slice_free(owl_zwrite, z);
    88    return NULL;
    99  }
     
    1313CALLER_OWN owl_zwrite *owl_zwrite_new(int argc, const char *const *argv)
    1414{
    15   owl_zwrite *z = g_new(owl_zwrite, 1);
     15  owl_zwrite *z = g_slice_new(owl_zwrite);
    1616  if (owl_zwrite_create(z, argc, argv) != 0) {
    17     g_free(z);
     17    g_slice_free(owl_zwrite, z);
    1818    return NULL;
    1919  }
     
    356356{
    357357  owl_zwrite_cleanup(z);
    358   g_free(z);
     358  g_slice_free(owl_zwrite, z);
    359359}
    360360
Note: See TracChangeset for help on using the changeset viewer.