use-gslice.diff
changeset 92 66f7e2aa040c
parent 87 78238d26911a
equal deleted inserted replaced
91:51d326d5cb92 92:66f7e2aa040c
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent c45500769f0c34734851c9079e57add63d083c25
     2 # Parent c45500769f0c34734851c9079e57add63d083c25
       
     3 # Parent  a18571d686cd4eddcb55e356a8b82c0ac3990f49
     3 Use glib slices to allocate constant-size blocks
     4 Use glib slices to allocate constant-size blocks
     4 
     5 
     5 diff -r c45500769f0c mcabber/mcabber/caps.c
     6 diff -r a18571d686cd mcabber/mcabber/caps.c
     6 --- a/mcabber/mcabber/caps.c	Wed Nov 12 02:43:42 2014 +0200
     7 --- a/mcabber/mcabber/caps.c	Fri Dec 09 01:38:39 2016 +0200
     7 +++ b/mcabber/mcabber/caps.c	Wed Nov 12 03:30:06 2014 +0200
     8 +++ b/mcabber/mcabber/caps.c	Fri Dec 09 01:48:31 2016 +0200
     8 @@ -52,7 +52,7 @@
     9 @@ -50,7 +50,7 @@
     9    g_hash_table_destroy(c->identities);
    10    g_hash_table_destroy(c->identities);
    10    g_hash_table_destroy(c->features);
    11    g_hash_table_destroy(c->features);
    11    g_hash_table_destroy(c->forms);
    12    g_hash_table_destroy(c->forms);
    12 -  g_free(c);
    13 -  g_free(c);
    13 +  g_slice_free(caps, c);
    14 +  g_slice_free(caps, c);
    14  }
    15  }
    15  
    16  
    16  void identity_destroy(gpointer data)
    17  void identity_destroy(gpointer data)
    17 @@ -61,14 +61,14 @@
    18 @@ -59,14 +59,14 @@
    18    g_free(i->category);
    19    g_free(i->category);
    19    g_free(i->type);
    20    g_free(i->type);
    20    g_free(i->name);
    21    g_free(i->name);
    21 -  g_free(i);
    22 -  g_free(i);
    22 +  g_slice_free(identity, i);
    23 +  g_slice_free(identity, i);
    29 -  g_free(f);
    30 -  g_free(f);
    30 +  g_slice_free(dataform, f);
    31 +  g_slice_free(dataform, f);
    31  }
    32  }
    32  
    33  
    33  void field_destroy(gpointer data)
    34  void field_destroy(gpointer data)
    34 @@ -97,7 +97,7 @@
    35 @@ -95,7 +95,7 @@
    35  {
    36  {
    36    if (!hash)
    37    if (!hash)
    37      return;
    38      return;
    38 -  caps *c = g_new0(caps, 1);
    39 -  caps *c = g_new0(caps, 1);
    39 +  caps *c = g_slice_new(caps);
    40 +  caps *c = g_slice_new(caps);
    40    c->features = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
    41    c->features = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
    41    c->identities = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, identity_destroy);
    42    c->identities = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, identity_destroy);
    42    c->forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, form_destroy);
    43    c->forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, form_destroy);
    43 @@ -158,7 +158,7 @@
    44 @@ -156,7 +156,7 @@
    44  
    45  
    45    c = g_hash_table_lookup(caps_cache, hash);
    46    c = g_hash_table_lookup(caps_cache, hash);
    46    if (c) {
    47    if (c) {
    47 -    identity *i = g_new0(identity, 1);
    48 -    identity *i = g_new0(identity, 1);
    48 +    identity *i = g_slice_new(identity);
    49 +    identity *i = g_slice_new(identity);
    49  
    50  
    50      i->category = g_strdup(category);
    51      i->category = g_strdup(category);
    51      i->name = g_strdup(name);
    52      i->name = g_strdup(name);
    52 @@ -182,7 +182,7 @@
    53 @@ -180,7 +180,7 @@
    53      return;
    54      return;
    54    c = g_hash_table_lookup(caps_cache, hash);
    55    c = g_hash_table_lookup(caps_cache, hash);
    55    if (c) {
    56    if (c) {
    56 -    dataform *d = g_new0(dataform, 1);
    57 -    dataform *d = g_new0(dataform, 1);
    57 +    dataform *d = g_slice_new(dataform);
    58 +    dataform *d = g_slice_new(dataform);
    58      char *f = g_strdup(formtype);
    59      char *f = g_strdup(formtype);
    59  
    60  
    60      d->fields = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, field_destroy);
    61      d->fields = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, field_destroy);
    61 diff -r c45500769f0c mcabber/mcabber/commands.c
    62 diff -r a18571d686cd mcabber/mcabber/commands.c
    62 --- a/mcabber/mcabber/commands.c	Wed Nov 12 02:43:42 2014 +0200
    63 --- a/mcabber/mcabber/commands.c	Fri Dec 09 01:38:39 2016 +0200
    63 +++ b/mcabber/mcabber/commands.c	Wed Nov 12 03:30:06 2014 +0200
    64 +++ b/mcabber/mcabber/commands.c	Fri Dec 09 01:48:31 2016 +0200
    64 @@ -115,7 +115,7 @@
    65 @@ -113,7 +113,7 @@
    65        gpointer userdata = command->userdata;
    66        gpointer userdata = command->userdata;
    66        Commands = g_slist_delete_link(Commands, sl_cmd);
    67        Commands = g_slist_delete_link(Commands, sl_cmd);
    67        compl_del_category_word(COMPL_CMD, command->name);
    68        compl_del_category_word(COMPL_CMD, command->name);
    68 -      g_free(command);
    69 -      g_free(command);
    69 +      g_slice_free(cmd, command);
    70 +      g_slice_free(cmd, command);
    70        return userdata;
    71        return userdata;
    71      }
    72      }
    72    return NULL;
    73    return NULL;
    73 @@ -127,7 +127,7 @@
    74 @@ -125,7 +125,7 @@
    74  gpointer cmd_add(const char *name, const char *help, guint flags_row1,
    75  gpointer cmd_add(const char *name, const char *help, guint flags_row1,
    75                   guint flags_row2, void (*f)(char*), gpointer userdata)
    76                   guint flags_row2, void (*f)(char*), gpointer userdata)
    76  {
    77  {
    77 -  cmd *n_cmd = g_new0(cmd, 1);
    78 -  cmd *n_cmd = g_new0(cmd, 1);
    78 +  cmd *n_cmd = g_slice_new0(cmd);
    79 +  cmd *n_cmd = g_slice_new0(cmd);
   113 -  g_free(msgbuf);
   114 -  g_free(msgbuf);
   114 +  g_slice_free1(HBB_BLOCKSIZE, msgbuf);
   115 +  g_slice_free1(HBB_BLOCKSIZE, msgbuf);
   115    return msgbuf_utf8;
   116    return msgbuf_utf8;
   116  }
   117  }
   117  
   118  
   118 @@ -1906,7 +1906,7 @@
   119 @@ -1921,7 +1921,7 @@
   119    esub   = buddy_getsubscription(bud);
   120    esub   = buddy_getsubscription(bud);
   120    on_srv = buddy_getonserverflag(bud);
   121    on_srv = buddy_getonserverflag(bud);
   121  
   122  
   122 -  buffer = g_new(char, 4096);
   123 -  buffer = g_new(char, 4096);
   123 +  buffer = g_slice_alloc(4096);
   124 +  buffer = g_slice_alloc(4096);
   124  
   125  
   125    if (bjid) {
   126    if (bjid) {
   126      GSList *resources, *p_res;
   127      GSList *resources, *p_res;
   127 @@ -2005,7 +2005,7 @@
   128 @@ -2020,7 +2020,7 @@
   128                   type == ROSTER_TYPE_GROUP ? "group" :
   129                   type == ROSTER_TYPE_GROUP ? "group" :
   129                   (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown"));
   130                   (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown"));
   130    }
   131    }
   131 -  g_free(buffer);
   132 -  g_free(buffer);
   132 +  g_slice_free1(4096, buffer);
   133 +  g_slice_free1(4096, buffer);
   133  
   134  
   134    // Tell the user if this item has an annotation.
   135    // Tell the user if this item has an annotation.
   135    if (type == ROSTER_TYPE_USER ||
   136    if (type == ROSTER_TYPE_USER ||
   136 @@ -2054,7 +2054,7 @@
   137 @@ -2069,7 +2069,7 @@
   137  
   138  
   138    bjid = buddy_getjid(bud);
   139    bjid = buddy_getjid(bud);
   139  
   140  
   140 -  buffer = g_new(char, 4096);
   141 -  buffer = g_new(char, 4096);
   141 +  buffer = g_slice_alloc(4096);
   142 +  buffer = g_slice_alloc(4096);
   142    strncpy(buffer, "Room members:", 127);
   143    strncpy(buffer, "Room members:", 127);
   143    scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
   144    scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
   144  
   145  
   145 @@ -2114,7 +2114,7 @@
   146 @@ -2129,7 +2129,7 @@
   146    scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
   147    scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
   147  
   148  
   148    g_slist_free(resources);
   149    g_slist_free(resources);
   149 -  g_free(buffer);
   150 -  g_free(buffer);
   150 +  g_slice_free1(4096, buffer);
   151 +  g_slice_free1(4096, buffer);
   151  }
   152  }
   152  
   153  
   153  static void move_group_member(gpointer bud, void *groupnamedata)
   154  static void move_group_member(gpointer bud, void *groupnamedata)
   154 @@ -3137,7 +3137,7 @@
   155 @@ -3163,7 +3163,7 @@
   155    affil = buddy_getaffil(bud, nick);
   156    affil = buddy_getaffil(bud, nick);
   156    realjid = buddy_getrjid(bud, nick);
   157    realjid = buddy_getrjid(bud, nick);
   157  
   158  
   158 -  buffer = g_new(char, 4096);
   159 -  buffer = g_new(char, 4096);
   159 +  buffer = g_slice_alloc(4096);
   160 +  buffer = g_slice_alloc(4096);
   160  
   161  
   161    snprintf(buffer, 4095, "Whois [%s]", nick);
   162    snprintf(buffer, 4095, "Whois [%s]", nick);
   162    scr_WriteIncomingMessage(bjid, buffer, 0, msg_flag, 0);
   163    scr_WriteIncomingMessage(bjid, buffer, 0, msg_flag, 0);
   163 @@ -3167,7 +3167,7 @@
   164 @@ -3193,7 +3193,7 @@
   164  
   165  
   165    scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, msg_flag, 0);
   166    scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, msg_flag, 0);
   166  
   167  
   167 -  g_free(buffer);
   168 -  g_free(buffer);
   168 +  g_slice_free1(4096, buffer);
   169 +  g_slice_free1(4096, buffer);
   169    g_free(nick);
   170    g_free(nick);
   170    if (paramlst)
   171    if (paramlst)
   171      free_arg_lst(paramlst);
   172      free_arg_lst(paramlst);
   172 diff -r c45500769f0c mcabber/mcabber/events.c
   173 diff -r a18571d686cd mcabber/mcabber/events.c
   173 --- a/mcabber/mcabber/events.c	Wed Nov 12 02:43:42 2014 +0200
   174 --- a/mcabber/mcabber/events.c	Fri Dec 09 01:38:39 2016 +0200
   174 +++ b/mcabber/mcabber/events.c	Wed Nov 12 03:30:06 2014 +0200
   175 +++ b/mcabber/mcabber/events.c	Fri Dec 09 01:48:31 2016 +0200
   175 @@ -83,7 +83,7 @@
   176 @@ -81,7 +81,7 @@
   176      return NULL;
   177      return NULL;
   177    }
   178    }
   178  
   179  
   179 -  event = g_new(evs_t, 1);
   180 -  event = g_new(evs_t, 1);
   180 +  event = g_slice_new(evs_t);
   181 +  event = g_slice_new(evs_t);
   197 -    g_free(event);
   198 -    g_free(event);
   198 +    g_slice_free(evs_t, event);
   199 +    g_slice_free(evs_t, event);
   199    }
   200    }
   200    g_slist_free(evs_list);
   201    g_slist_free(evs_list);
   201    evs_list = NULL;
   202    evs_list = NULL;
   202 diff -r c45500769f0c mcabber/mcabber/hbuf.c
   203 diff -r a18571d686cd mcabber/mcabber/hbuf.c
   203 --- a/mcabber/mcabber/hbuf.c	Wed Nov 12 02:43:42 2014 +0200
   204 --- a/mcabber/mcabber/hbuf.c	Fri Dec 09 01:38:39 2016 +0200
   204 +++ b/mcabber/mcabber/hbuf.c	Wed Nov 12 03:30:06 2014 +0200
   205 +++ b/mcabber/mcabber/hbuf.c	Fri Dec 09 01:48:31 2016 +0200
   205 @@ -29,7 +29,6 @@
   206 @@ -27,7 +27,6 @@
   206  #include "utf8.h"
   207  #include "utf8.h"
   207  #include "screen.h"
   208  #include "screen.h"
   208  
   209  
   209 -
   210 -
   210  /* This is a private structure type */
   211  /* This is a private structure type */
   211  
   212  
   212  typedef struct {
   213  typedef struct {
   213 @@ -59,7 +58,7 @@
   214 @@ -57,7 +56,7 @@
   214  {
   215  {
   215    GList *curr_elt = first_hbuf_elt;
   216    GList *curr_elt = first_hbuf_elt;
   216  
   217  
   217 -  // Let's add non-persistent blocs if necessary
   218 -  // Let's add non-persistent blocs if necessary
   218 +  // Let's add non-persistent blocks if necessary
   219 +  // Let's add non-persistent blocks if necessary
   219    // - If there are '\n' in the string
   220    // - If there are '\n' in the string
   220    // - If length > width (and width != 0)
   221    // - If length > width (and width != 0)
   221    while (curr_elt) {
   222    while (curr_elt) {
   222 @@ -95,17 +94,21 @@
   223 @@ -93,17 +92,21 @@
   223        end = hbuf_b_curr->ptr_end;
   224        end = hbuf_b_curr->ptr_end;
   224        hbuf_b_curr->ptr_end = br;
   225        hbuf_b_curr->ptr_end = br;
   225        // Create another block
   226        // Create another block
   226 -      hbuf_b_curr = g_new0(hbuf_block, 1);
   227 -      hbuf_b_curr = g_new0(hbuf_block, 1);
   227 +      hbuf_b_curr = g_slice_new(hbuf_block);
   228 +      hbuf_b_curr = g_slice_new(hbuf_block);
   242 +      hbuf_b_curr->prefix.mucnicklen = 0;
   243 +      hbuf_b_curr->prefix.mucnicklen = 0;
   243 +      hbuf_b_curr->prefix.xep184     = NULL;
   244 +      hbuf_b_curr->prefix.xep184     = NULL;
   244        // This is OK because insert_before(NULL) == append():
   245        // This is OK because insert_before(NULL) == append():
   245        *p_hbuf = g_list_insert_before(*p_hbuf, curr_elt->next, hbuf_b_curr);
   246        *p_hbuf = g_list_insert_before(*p_hbuf, curr_elt->next, hbuf_b_curr);
   246      }
   247      }
   247 @@ -138,7 +141,7 @@
   248 @@ -136,7 +139,7 @@
   248    textlen = strlen(text);
   249    textlen = strlen(text);
   249    hbb_blocksize = MAX(textlen+1, HBB_BLOCKSIZE);
   250    hbb_blocksize = MAX(textlen+1, HBB_BLOCKSIZE);
   250  
   251  
   251 -  hbuf_block_elt = g_new0(hbuf_block, 1);
   252 -  hbuf_block_elt = g_new0(hbuf_block, 1);
   252 +  hbuf_block_elt = g_slice_new(hbuf_block);
   253 +  hbuf_block_elt = g_slice_new(hbuf_block);
   253    hbuf_block_elt->prefix.timestamp  = timestamp;
   254    hbuf_block_elt->prefix.timestamp  = timestamp;
   254    hbuf_block_elt->prefix.flags      = prefix_flags;
   255    hbuf_block_elt->prefix.flags      = prefix_flags;
   255    hbuf_block_elt->prefix.mucnicklen = mucnicklen;
   256    hbuf_block_elt->prefix.mucnicklen = mucnicklen;
   256 @@ -146,7 +149,7 @@
   257 @@ -144,7 +147,7 @@
   257    if (!*p_hbuf) {
   258    if (!*p_hbuf) {
   258      hbuf_block_elt->ptr  = g_new(char, hbb_blocksize);
   259      hbuf_block_elt->ptr  = g_new(char, hbb_blocksize);
   259      if (!hbuf_block_elt->ptr) {
   260      if (!hbuf_block_elt->ptr) {
   260 -      g_free(hbuf_block_elt);
   261 -      g_free(hbuf_block_elt);
   261 +      g_slice_free(hbuf_block, hbuf_block_elt);
   262 +      g_slice_free(hbuf_block, hbuf_block_elt);
   262        return;
   263        return;
   263      }
   264      }
   264      hbuf_block_elt->flags  = HBB_FLAG_ALLOC | HBB_FLAG_PERSISTENT;
   265      hbuf_block_elt->flags  = HBB_FLAG_ALLOC | HBB_FLAG_PERSISTENT;
   265 @@ -208,7 +211,7 @@
   266 @@ -206,7 +209,7 @@
   266                  g_free(hbuf_b_elt->ptr);
   267                  g_free(hbuf_b_elt->ptr);
   267                }
   268                }
   268              }
   269              }
   269 -            g_free(hbuf_b_elt);
   270 -            g_free(hbuf_b_elt);
   270 +            g_slice_free(hbuf_block, hbuf_b_elt);
   271 +            g_slice_free(hbuf_block, hbuf_b_elt);
   271              hbuf_head = *p_hbuf = g_list_delete_link(hbuf_head, hbuf_elt);
   272              hbuf_head = *p_hbuf = g_list_delete_link(hbuf_head, hbuf_elt);
   272            }
   273            }
   273            n--;
   274            n--;
   274 @@ -245,7 +248,7 @@
   275 @@ -243,7 +246,7 @@
   275      if (hbuf_b_elt->flags & HBB_FLAG_ALLOC) {
   276      if (hbuf_b_elt->flags & HBB_FLAG_ALLOC) {
   276        g_free(hbuf_b_elt->ptr);
   277        g_free(hbuf_b_elt->ptr);
   277      }
   278      }
   278 -    g_free(hbuf_b_elt);
   279 -    g_free(hbuf_b_elt);
   279 +    g_slice_free(hbuf_block, hbuf_b_elt);
   280 +    g_slice_free(hbuf_block, hbuf_b_elt);
   280    }
   281    }
   281  
   282  
   282    g_list_free(first_elt);
   283    g_list_free(first_elt);
   283 @@ -275,7 +278,7 @@
   284 @@ -273,7 +276,7 @@
   284      // Is next line not-persistent?
   285      // Is next line not-persistent?
   285      if (!(hbuf_b_next->flags & HBB_FLAG_PERSISTENT)) {
   286      if (!(hbuf_b_next->flags & HBB_FLAG_PERSISTENT)) {
   286        hbuf_b_curr->ptr_end = hbuf_b_next->ptr_end;
   287        hbuf_b_curr->ptr_end = hbuf_b_next->ptr_end;
   287 -      g_free(hbuf_b_next);
   288 -      g_free(hbuf_b_next);
   288 +      g_slice_free(hbuf_block, hbuf_b_next);
   289 +      g_slice_free(hbuf_block, hbuf_b_next);
   289        curr_elt = g_list_delete_link(curr_elt, next_elt);
   290        curr_elt = g_list_delete_link(curr_elt, next_elt);
   290      } else
   291      } else
   291        curr_elt = next_elt;
   292        curr_elt = next_elt;
   292 @@ -309,8 +312,8 @@
   293 @@ -307,8 +310,8 @@
   293  //  hbuf_get_lines(hbuf, n)
   294  //  hbuf_get_lines(hbuf, n)
   294  // Returns an array of n hbb_line pointers
   295  // Returns an array of n hbb_line pointers
   295  // (The first line will be the line currently pointed by hbuf)
   296  // (The first line will be the line currently pointed by hbuf)
   296 -// Note: The caller should free the array, the hbb_line pointers and the
   297 -// Note: The caller should free the array, the hbb_line pointers and the
   297 -// text pointers after use.
   298 -// text pointers after use.
   298 +// Note: The caller should g_free the array, g_slice_free hbb_line pointers
   299 +// Note: The caller should g_free the array, g_slice_free hbb_line pointers
   299 +// and g_free text pointers after use.
   300 +// and g_free text pointers after use.
   300  hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n)
   301  hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n)
   301  {
   302  {
   302    unsigned int i;
   303    unsigned int i;
   303 @@ -349,7 +352,7 @@
   304 @@ -347,7 +350,7 @@
   304  
   305  
   305        blk = (hbuf_block*)(hbuf->data);
   306        blk = (hbuf_block*)(hbuf->data);
   306        maxlen = blk->ptr_end - blk->ptr;
   307        maxlen = blk->ptr_end - blk->ptr;
   307 -      *array_elt = (hbb_line*)g_new(hbb_line, 1);
   308 -      *array_elt = (hbb_line*)g_new(hbb_line, 1);
   308 +      *array_elt = (hbb_line*)g_slice_new(hbb_line);
   309 +      *array_elt = (hbb_line*)g_slice_new(hbb_line);
   309        (*array_elt)->timestamp  = blk->prefix.timestamp;
   310        (*array_elt)->timestamp  = blk->prefix.timestamp;
   310        (*array_elt)->flags      = blk->prefix.flags;
   311        (*array_elt)->flags      = blk->prefix.flags;
   311        (*array_elt)->mucnicklen = blk->prefix.mucnicklen;
   312        (*array_elt)->mucnicklen = blk->prefix.mucnicklen;
   312 diff -r c45500769f0c mcabber/mcabber/hooks.c
   313 diff -r a18571d686cd mcabber/mcabber/hooks.c
   313 --- a/mcabber/mcabber/hooks.c	Wed Nov 12 02:43:42 2014 +0200
   314 --- a/mcabber/mcabber/hooks.c	Fri Dec 09 01:38:39 2016 +0200
   314 +++ b/mcabber/mcabber/hooks.c	Wed Nov 12 03:30:06 2014 +0200
   315 +++ b/mcabber/mcabber/hooks.c	Fri Dec 09 01:48:31 2016 +0200
   315 @@ -99,7 +99,7 @@
   316 @@ -99,7 +99,7 @@
   316                       gint priority, gpointer userdata)
   317                       gint priority, gpointer userdata)
   317  {
   318  {
   318    GSList **hqueue = NULL;
   319    GSList **hqueue = NULL;
   319 -  hook_list_data_t *h = g_new(hook_list_data_t, 1);
   320 -  hook_list_data_t *h = g_new(hook_list_data_t, 1);
   328 -    g_free(el->data);
   329 -    g_free(el->data);
   329 +    g_slice_free(hook_list_data_t, el->data);
   330 +    g_slice_free(hook_list_data_t, el->data);
   330      *hqueue = g_slist_delete_link(*hqueue, el);
   331      *hqueue = g_slist_delete_link(*hqueue, el);
   331      // Remove hook hash table entry if the hook queue is empty
   332      // Remove hook hash table entry if the hook queue is empty
   332      if (!*hqueue)
   333      if (!*hqueue)
   333 diff -r c45500769f0c mcabber/mcabber/modules.c
   334 diff -r a18571d686cd mcabber/mcabber/modules.c
   334 --- a/mcabber/mcabber/modules.c	Wed Nov 12 02:43:42 2014 +0200
   335 --- a/mcabber/mcabber/modules.c	Fri Dec 09 01:38:39 2016 +0200
   335 +++ b/mcabber/mcabber/modules.c	Wed Nov 12 03:30:06 2014 +0200
   336 +++ b/mcabber/mcabber/modules.c	Fri Dec 09 01:48:31 2016 +0200
   336 @@ -176,7 +176,7 @@
   337 @@ -174,7 +174,7 @@
   337    }
   338    }
   338  
   339  
   339    { // Register module
   340    { // Register module
   340 -    loaded_module_t *module = g_new(loaded_module_t, 1);
   341 -    loaded_module_t *module = g_new(loaded_module_t, 1);
   341 +    loaded_module_t *module = g_slice_new(loaded_module_t);
   342 +    loaded_module_t *module = g_slice_new(loaded_module_t);
   342  
   343  
   343      module->refcount     = 1;
   344      module->refcount     = 1;
   344      module->locked       = manual;
   345      module->locked       = manual;
   345 @@ -267,7 +267,7 @@
   346 @@ -265,7 +265,7 @@
   346    // Output this here, as arg may point to module->name
   347    // Output this here, as arg may point to module->name
   347    scr_LogPrint(LPRINT_LOGNORM, "Unloaded module %s.", module->name);
   348    scr_LogPrint(LPRINT_LOGNORM, "Unloaded module %s.", module->name);
   348    g_free(module->name);
   349    g_free(module->name);
   349 -  g_free(module);
   350 -  g_free(module);
   350 +  g_slice_free(loaded_module_t, module);
   351 +  g_slice_free(loaded_module_t, module);
   351  
   352  
   352    return NULL;
   353    return NULL;
   353  }
   354  }
   354 diff -r c45500769f0c mcabber/mcabber/screen.c
   355 diff -r a18571d686cd mcabber/mcabber/screen.c
   355 --- a/mcabber/mcabber/screen.c	Wed Nov 12 02:43:42 2014 +0200
   356 --- a/mcabber/mcabber/screen.c	Fri Dec 09 01:38:39 2016 +0200
   356 +++ b/mcabber/mcabber/screen.c	Wed Nov 12 03:30:06 2014 +0200
   357 +++ b/mcabber/mcabber/screen.c	Fri Dec 09 01:48:31 2016 +0200
   357 @@ -1360,7 +1360,7 @@
   358 @@ -1368,7 +1368,7 @@
   358          wattrset(win_entry->win, get_color(COLOR_GENERAL));
   359          wattrset(win_entry->win, get_color(COLOR_GENERAL));
   359  
   360  
   360        g_free(line->text);
   361        g_free(line->text);
   361 -      g_free(line);
   362 -      g_free(line);
   362 +      g_slice_free(hbb_line, line);
   363 +      g_slice_free(hbb_line, line);
   363      } else {
   364      } else {
   364        wclrtobot(win_entry->win);
   365        wclrtobot(win_entry->win);
   365        break;
   366        break;
   366 @@ -1374,7 +1374,7 @@
   367 @@ -1382,7 +1382,7 @@
   367        scr_buffer_scroll_lock(1);
   368        scr_buffer_scroll_lock(1);
   368      }
   369      }
   369      g_free(line->text);
   370      g_free(line->text);
   370 -    g_free(line);
   371 -    g_free(line);
   371 +    g_slice_free(hbb_line, line);
   372 +    g_slice_free(hbb_line, line);
   372    } else if (autolock && win_entry->bd->lock) {
   373    } else if (autolock && win_entry->bd->lock) {
   373      scr_buffer_scroll_lock(0);
   374      scr_buffer_scroll_lock(0);
   374    }
   375    }
   375 diff -r c45500769f0c mcabber/mcabber/settings.c
   376 diff -r a18571d686cd mcabber/mcabber/settings.c
   376 --- a/mcabber/mcabber/settings.c	Wed Nov 12 02:43:42 2014 +0200
   377 --- a/mcabber/mcabber/settings.c	Fri Dec 09 01:38:39 2016 +0200
   377 +++ b/mcabber/mcabber/settings.c	Wed Nov 12 03:30:06 2014 +0200
   378 +++ b/mcabber/mcabber/settings.c	Fri Dec 09 01:48:31 2016 +0200
   378 @@ -457,7 +457,7 @@
   379 @@ -528,7 +528,7 @@
   379      // If value is 0, we do not need to create a structure (that's
   380      // If value is 0, we do not need to create a structure (that's
   380      // the default value).
   381      // the default value).
   381      if (value) {
   382      if (value) {
   382 -      pgpdata = g_new0(T_pgpopt, 1);
   383 -      pgpdata = g_new0(T_pgpopt, 1);
   383 +      pgpdata = g_slice_new0(T_pgpopt);
   384 +      pgpdata = g_slice_new0(T_pgpopt);
   384        pgpdata->pgp_disabled = value;
   385        pgpdata->pgp_disabled = value;
   385        g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
   386        g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
   386      }
   387      }
   387 @@ -497,7 +497,7 @@
   388 @@ -568,7 +568,7 @@
   388      // If value is 0, we do not need to create a structure (that's
   389      // If value is 0, we do not need to create a structure (that's
   389      // the default value).
   390      // the default value).
   390      if (value) {
   391      if (value) {
   391 -      pgpdata = g_new0(T_pgpopt, 1);
   392 -      pgpdata = g_new0(T_pgpopt, 1);
   392 +      pgpdata = g_slice_new0(T_pgpopt);
   393 +      pgpdata = g_slice_new0(T_pgpopt);
   393        pgpdata->pgp_force = value;
   394        pgpdata->pgp_force = value;
   394        g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
   395        g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
   395      }
   396      }
   396 @@ -537,7 +537,7 @@
   397 @@ -608,7 +608,7 @@
   397      // If keyid is NULL, we do not need to create a structure (that's
   398      // If keyid is NULL, we do not need to create a structure (that's
   398      // the default value).
   399      // the default value).
   399      if (keyid) {
   400      if (keyid) {
   400 -      pgpdata = g_new0(T_pgpopt, 1);
   401 -      pgpdata = g_new0(T_pgpopt, 1);
   401 +      pgpdata = g_slice_new0(T_pgpopt);
   402 +      pgpdata = g_slice_new0(T_pgpopt);
   402        pgpdata->pgp_keyid = g_strdup(keyid);
   403        pgpdata->pgp_keyid = g_strdup(keyid);
   403        g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
   404        g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
   404      }
   405      }
   405 diff -r c45500769f0c mcabber/mcabber/xmpp_iq.c
   406 diff -r a18571d686cd mcabber/mcabber/xmpp_iq.c
   406 --- a/mcabber/mcabber/xmpp_iq.c	Wed Nov 12 02:43:42 2014 +0200
   407 --- a/mcabber/mcabber/xmpp_iq.c	Fri Dec 09 01:38:39 2016 +0200
   407 +++ b/mcabber/mcabber/xmpp_iq.c	Wed Nov 12 03:30:06 2014 +0200
   408 +++ b/mcabber/mcabber/xmpp_iq.c	Fri Dec 09 01:48:31 2016 +0200
   408 @@ -765,7 +765,7 @@
   409 @@ -791,7 +791,7 @@
   409      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   410      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   410    }
   411    }
   411  
   412  
   412 -  buf = g_new0(char, 512);
   413 -  buf = g_new0(char, 512);
   413 +  buf = g_slice_alloc(512);
   414 +  buf = g_slice_alloc(512);
   414  
   415  
   415    r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
   416    r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
   416    query = lm_message_node_add_child(r->node, "query", NULL);
   417    query = lm_message_node_add_child(r->node, "query", NULL);
   417 @@ -792,7 +792,7 @@
   418 @@ -818,7 +818,7 @@
   418  
   419  
   419    lm_connection_send(c, r, NULL);
   420    lm_connection_send(c, r, NULL);
   420    lm_message_unref(r);
   421    lm_message_unref(r);
   421 -  g_free(buf);
   422 -  g_free(buf);
   422 +  g_slice_free1(512, buf);
   423 +  g_slice_free1(512, buf);
   423    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   424    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   424  }
   425  }
   425  
   426  
   426 @@ -820,7 +820,7 @@
   427 @@ -846,7 +846,7 @@
   427      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   428      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   428    }
   429    }
   429  
   430  
   430 -  buf = g_new0(char, 512);
   431 -  buf = g_new0(char, 512);
   431 +  buf = g_slice_alloc(512);
   432 +  buf = g_slice_alloc(512);
   432  
   433  
   433    r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
   434    r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
   434    query = lm_message_node_add_child(r->node, "time", NULL);
   435    query = lm_message_node_add_child(r->node, "time", NULL);
   435 @@ -857,7 +857,7 @@
   436 @@ -883,7 +883,7 @@
   436  
   437  
   437    lm_connection_send(c, r, NULL);
   438    lm_connection_send(c, r, NULL);
   438    lm_message_unref(r);
   439    lm_message_unref(r);
   439 -  g_free(buf);
   440 -  g_free(buf);
   440 +  g_slice_free1(512, buf);
   441 +  g_slice_free1(512, buf);