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

    rf271129 r7dcef03  
    3535void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
    3636  owl_cmd *cmd;
    37   cmd = g_new(owl_cmd, 1);
     37  cmd = g_slice_new(owl_cmd);
    3838  owl_cmd_create_alias(cmd, alias_from, alias_to);
    3939  owl_perlconfig_new_command(cmd->name);
     
    4242
    4343int owl_cmddict_add_cmd(owl_cmddict *cd, const owl_cmd * cmd) {
    44   owl_cmd * newcmd = g_new(owl_cmd, 1);
     44  owl_cmd * newcmd = g_slice_new(owl_cmd);
    4545  if(owl_cmd_create_from_template(newcmd, cmd) < 0) {
    46     g_free(newcmd);
     46    g_slice_free(owl_cmd, newcmd);
    4747    return -1;
    4848  }
     
    141141{
    142142  owl_cmd_cleanup(cmd);
    143   g_free(cmd);
     143  g_slice_free(owl_cmd, cmd);
    144144}
    145145
Note: See TracChangeset for help on using the changeset viewer.