Changeset 7dcef03 for functions.c


Ignore:
Timestamp:
Dec 25, 2013, 11:33:37 AM (10 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10
Children:
8f95fc4, 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
  • functions.c

    rc55930e r7dcef03  
    196196  owl_message *m;
    197197
    198   m=g_new(owl_message, 1);
     198  m=g_slice_new(owl_message);
    199199  owl_message_create_admin(m, header, body);
    200200 
     
    218218  if (z->cc && owl_zwrite_is_personal(z)) {
    219219    /* create the message */
    220     owl_message *m = g_new(owl_message, 1);
     220    owl_message *m = g_slice_new(owl_message);
    221221    owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), 0);
    222222
     
    231231
    232232      /* create the message */
    233       m = g_new(owl_message, 1);
     233      m = g_slice_new(owl_message);
    234234      owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i);
    235235
     
    251251  if (!owl_global_is_aimloggedin(&g)) return(NULL);
    252252 
    253   m=g_new(owl_message, 1);
     253  m=g_slice_new(owl_message);
    254254  owl_message_create_aim(m,
    255255                         owl_global_get_aim_screenname(&g),
     
    270270
    271271  /* create the message */
    272   m=g_new(owl_message, 1);
     272  m=g_slice_new(owl_message);
    273273  owl_message_create_loopback(m, body);
    274274  owl_message_set_direction_out(m);
     
    516516  /* create a message and put it on the message queue.  This simulates
    517517   * an incoming message */
    518   min=g_new(owl_message, 1);
     518  min=g_slice_new(owl_message);
    519519  mout=owl_function_make_outgoing_loopback(msg);
    520520
     
    34823482  while (zaldptr) {
    34833483    ZFreeALD(zaldptr->data);
    3484     g_free(zaldptr->data);
     3484    g_slice_free(ZAsyncLocateData_t, zaldptr->data);
    34853485    zaldptr = g_list_next(zaldptr);
    34863486  }
     
    34923492    for (i = 0; i < anyone->len; i++) {
    34933493      user = anyone->pdata[i];
    3494       zald = g_new(ZAsyncLocateData_t, 1);
     3494      zald = g_slice_new(ZAsyncLocateData_t);
    34953495      if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
    34963496        *zaldlist = g_list_append(*zaldlist, zald);
    34973497      } else {
    3498         g_free(zald);
     3498        g_slice_free(ZAsyncLocateData_t, zald);
    34993499      }
    35003500    }
Note: See TracChangeset for help on using the changeset viewer.