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

    rebcdf4d r7dcef03  
    125125    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
    126126    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
    127     g_free(subs);
     127    g_slice_free(owl_sub_list, subs);
    128128  }
    129129
     
    261261    g_free(subs);
    262262  } else {
    263     owl_sub_list *s = g_new(owl_sub_list, 1);
     263    owl_sub_list *s = g_slice_new(owl_sub_list);
    264264    s->subs = subs;
    265265    s->nsubs = count;
     
    14131413          if (ret == ZERR_NONE) {
    14141414            /* Send a PSEUDO LOGIN! */
    1415             m = g_new(owl_message, 1);
     1415            m = g_slice_new(owl_message);
    14161416            owl_message_create_pseudo_zlogin(m, 0, zald->user,
    14171417                                             location.host,
     
    14261426        /* Send a PSEUDO LOGOUT! */
    14271427        if (notify) {
    1428           m = g_new(owl_message, 1);
     1428          m = g_slice_new(owl_message);
    14291429          owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", "");
    14301430          owl_global_messagequeue_addmsg(&g, m);
     
    14351435    }
    14361436    ZFreeALD(zald);
    1437     g_free(zald);
     1437    g_slice_free(ZAsyncLocateData_t, zald);
    14381438  }
    14391439}
     
    15021502
    15031503      /* create the new message */
    1504       m=g_new(owl_message, 1);
     1504      m=g_slice_new(owl_message);
    15051505      owl_message_create_from_znotice(m, &notice);
    15061506
Note: See TracChangeset for help on using the changeset viewer.