]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Further g_slice cleanup
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 Oct 2017 22:54:00 +0000 (23:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 Oct 2017 22:54:00 +0000 (23:54 +0100)
src/libstat/tokenizers/osb.c
src/libutil/regexp.c
src/libutil/rrd.c
src/libutil/shingles.c
src/libutil/upstream.c
src/libutil/util.c
src/lua/lua_redis.c
src/lua/lua_regexp.c
src/lua/lua_tcp.c

index 54668e758b92fb08367969818ee39e9fb298c233..f6f46c5808ea4c7c162281562a3a1865b08cc5e4 100644 (file)
@@ -85,10 +85,10 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool,
 
 
        if (pool != NULL) {
-               cf = rspamd_mempool_alloc (pool, sizeof (*cf));
+               cf = rspamd_mempool_alloc0 (pool, sizeof (*cf));
        }
        else {
-               cf = g_slice_alloc (sizeof (*cf));
+               cf = g_malloc0 (sizeof (*cf));
        }
 
        /* Use default config */
index 1d04b83f97c22d31d427a81b1aa497004153bdb4..8174a30fce3efb76b13f617e64310d8ca39cf77a 100644 (file)
@@ -156,7 +156,7 @@ rspamd_regexp_dtor (rspamd_regexp_t *re)
                        g_free (re->pattern);
                }
 
-               g_slice_free1 (sizeof (*re), re);
+               g_free (re);
        }
 }
 
@@ -464,7 +464,7 @@ fin:
        }
 
        /* Now allocate the target structure */
-       res = g_slice_alloc0 (sizeof (*res));
+       res = g_malloc0 (sizeof (*res));
        REF_INIT_RETAIN (res, rspamd_regexp_dtor);
        res->flags = rspamd_flags;
        res->pattern = real_pattern;
@@ -946,7 +946,7 @@ rspamd_regexp_cache_new (void)
 {
        struct rspamd_regexp_cache *ncache;
 
-       ncache = g_slice_alloc (sizeof (*ncache));
+       ncache = g_malloc0 (sizeof (*ncache));
        ncache->tbl = g_hash_table_new_full (rspamd_regexp_hash, rspamd_regexp_equal,
                        NULL, (GDestroyNotify)rspamd_regexp_unref);
 
index 026d0673f100d845fc86099e0f458f6b99e76087..3e67bb2a308cb939a161e0a1107207f987a11ea2 100644 (file)
@@ -406,7 +406,7 @@ rspamd_rrd_open_common (const gchar *filename, gboolean completed, GError **err)
                return NULL;
        }
 
-       file = g_slice_alloc0 (sizeof (struct rspamd_rrd_file));
+       file = g_malloc0 (sizeof (struct rspamd_rrd_file));
 
        if (file == NULL) {
                g_set_error (err, rrd_error_quark (), ENOMEM, "not enough memory");
@@ -438,7 +438,7 @@ rspamd_rrd_open_common (const gchar *filename, gboolean completed, GError **err)
                close (fd);
                g_set_error (err,
                        rrd_error_quark (), ENOMEM, "mmap failed: %s", strerror (errno));
-               g_slice_free1 (sizeof (struct rspamd_rrd_file), file);
+               g_free (file);
                return NULL;
        }
 
@@ -754,7 +754,7 @@ rspamd_rrd_finalize (struct rspamd_rrd_file *file, GError **err)
                close (fd);
                g_set_error (err,
                        rrd_error_quark (), ENOMEM, "mmap failed: %s", strerror (errno));
-               g_slice_free1 (sizeof (struct rspamd_rrd_file), file);
+               g_free (file);
                return FALSE;
        }
 
@@ -1265,7 +1265,7 @@ rspamd_rrd_close (struct rspamd_rrd_file * file)
        g_free (file->filename);
        g_free (file->id);
 
-       g_slice_free1 (sizeof (struct rspamd_rrd_file), file);
+       g_free (file);
 
        return 0;
 }
@@ -1489,7 +1489,7 @@ rspamd_rrd_query (struct rspamd_rrd_file *file,
                return NULL;
        }
 
-       res = g_slice_alloc0 (sizeof (*res));
+       res = g_malloc0 (sizeof (*res));
        res->ds_count = file->stat_head->ds_cnt;
        res->last_update = (gdouble)file->live_head->last_up +
                        ((gdouble)file->live_head->last_up_usec / 1e6f);
index 3e0c14b3ab31c722ac5e607a2339f1e1eea27ecd..240facc4a180c2e88e142186a4eede9bb0fb3bd4 100644 (file)
@@ -139,13 +139,13 @@ rspamd_shingles_from_text (GArray *input,
        row = rspamd_fstring_sized_new (256);
 
        /* Init hashes pipes and keys */
-       hashes = g_slice_alloc (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE);
+       hashes = g_malloc (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE);
        hlen = input->len > SHINGLES_WINDOW ?
                        (input->len - SHINGLES_WINDOW + 1) : 1;
        keys = rspamd_shingles_get_keys_cached (key);
 
        for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
-               hashes[i] = g_slice_alloc (hlen * sizeof (guint64));
+               hashes[i] = g_malloc (hlen * sizeof (guint64));
        }
 
        /* Now parse input words into a vector of hashes using rolling window */
@@ -222,10 +222,10 @@ rspamd_shingles_from_text (GArray *input,
        for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
                res->hashes[i] = filter (hashes[i], hlen,
                                i, key, filterd);
-               g_slice_free1 (hlen * sizeof (guint64), hashes[i]);
+               g_free (hashes[i]);
        }
 
-       g_slice_free1 (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE, hashes);
+       g_free (hashes);
 
        rspamd_fstring_free (row);
 
@@ -258,12 +258,12 @@ rspamd_shingles_from_image (guchar *dct,
        }
 
        /* Init hashes pipes and keys */
-       hashes = g_slice_alloc (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE);
+       hashes = g_malloc (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE);
        hlen = RSPAMD_DCT_LEN / NBBY  + 1;
        keys = rspamd_shingles_get_keys_cached (key);
 
        for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
-               hashes[i] = g_slice_alloc (hlen * sizeof (guint64));
+               hashes[i] = g_malloc (hlen * sizeof (guint64));
        }
 
        switch (alg) {
@@ -303,10 +303,10 @@ rspamd_shingles_from_image (guchar *dct,
        for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
                shingle->hashes[i] = filter (hashes[i], hlen,
                                i, key, filterd);
-               g_slice_free1 (hlen * sizeof (guint64), hashes[i]);
+               g_free (hashes[i]);
        }
 
-       g_slice_free1 (sizeof (*hashes) * RSPAMD_SHINGLE_SIZE, hashes);
+       g_free (hashes);
 
        return shingle;
 }
index ac15780adb9412d2e5e29a9377679703a2e98997..2f2772f92c72a6b7717f974d03c3ba1d34900e6f 100644 (file)
@@ -146,7 +146,7 @@ rspamd_upstream_ctx_dtor (struct upstream_ctx *ctx)
 
        g_queue_free (ctx->upstreams);
        rspamd_mempool_delete (ctx->pool);
-       g_slice_free1 (sizeof (*ctx), ctx);
+       g_free (ctx);
 }
 
 void
@@ -160,7 +160,7 @@ rspamd_upstreams_library_init (void)
 {
        struct upstream_ctx *ctx;
 
-       ctx = g_slice_alloc0 (sizeof (*ctx));
+       ctx = g_malloc0 (sizeof (*ctx));
        ctx->error_time = default_error_time;
        ctx->max_errors = default_max_errors;
        ctx->dns_retransmits = default_dns_retransmits;
@@ -227,7 +227,7 @@ rspamd_upstream_addr_elt_dtor (gpointer a)
        struct upstream_addr_elt *elt = a;
 
        rspamd_inet_address_free (elt->addr);
-       g_slice_free1 (sizeof (*elt), elt);
+       g_free (elt);
 }
 
 static void
@@ -262,7 +262,7 @@ rspamd_upstream_update_addrs (struct upstream *up)
                /* Copy addrs back */
                LL_FOREACH (up->new_addrs, cur) {
                        rspamd_inet_address_set_port (cur->addr, port);
-                       addr_elt = g_slice_alloc (sizeof (*addr_elt));
+                       addr_elt = g_malloc0 (sizeof (*addr_elt));
                        addr_elt->addr = cur->addr;
                        addr_elt->errors = 0;
                        g_ptr_array_add (new_addrs, addr_elt);
@@ -488,7 +488,7 @@ rspamd_upstreams_create (struct upstream_ctx *ctx)
 {
        struct upstream_list *ls;
 
-       ls = g_slice_alloc0 (sizeof (*ls));
+       ls = g_malloc0 (sizeof (*ls));
        ls->hash_seed = SEED_CONSTANT;
        ls->ups = g_ptr_array_new ();
        ls->alive = g_ptr_array_new ();
@@ -536,7 +536,7 @@ rspamd_upstream_dtor (struct upstream *up)
                REF_RELEASE (up->ctx);
        }
 
-       g_slice_free1 (sizeof (*up), up);
+       g_free (up);
 }
 
 rspamd_inet_addr_t*
@@ -573,7 +573,7 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups, const gchar *str,
        rspamd_inet_addr_t *addr;
        gboolean ret = FALSE;
 
-       up = g_slice_alloc0 (sizeof (*up));
+       up = g_malloc0 (sizeof (*up));
 
        switch (parse_type) {
        case RSPAMD_UPSTREAM_PARSE_DEFAULT:
@@ -607,7 +607,7 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups, const gchar *str,
        }
 
        if (!ret) {
-               g_slice_free1 (sizeof (*up), up);
+               g_free (up);
                return FALSE;
        }
        else {
@@ -667,7 +667,7 @@ rspamd_upstream_add_addr (struct upstream *up, rspamd_inet_addr_t *addr)
                up->addrs.addr = g_ptr_array_new_full (8, rspamd_upstream_addr_elt_dtor);
        }
 
-       elt = g_slice_alloc0 (sizeof (*elt));
+       elt = g_malloc0 (sizeof (*elt));
        elt->addr = addr;
        g_ptr_array_add (up->addrs.addr, elt);
        g_ptr_array_sort (up->addrs.addr, rspamd_upstream_addr_sort_func);
@@ -777,7 +777,7 @@ rspamd_upstreams_destroy (struct upstream_list *ups)
 
                g_ptr_array_free (ups->ups, TRUE);
                rspamd_mutex_free (ups->lock);
-               g_slice_free1 (sizeof (*ups), ups);
+               g_free (ups);
        }
 }
 
index 7840dc7449519651281a2ac01e98ff4fa9cabd66..fe092ad3c568fa27152a62e7bde7cdd3a7cc9184 100644 (file)
@@ -1481,7 +1481,7 @@ rspamd_mutex_new (void)
 {
        rspamd_mutex_t *new;
 
-       new = g_slice_alloc (sizeof (rspamd_mutex_t));
+       new = g_malloc0 (sizeof (rspamd_mutex_t));
 #if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
        g_mutex_init (&new->mtx);
 #else
@@ -1525,7 +1525,7 @@ rspamd_mutex_free (rspamd_mutex_t *mtx)
 #if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION > 30))
        g_mutex_clear (&mtx->mtx);
 #endif
-       g_slice_free1 (sizeof (rspamd_mutex_t), mtx);
+       g_free (mtx);
 }
 
 struct rspamd_thread_data {
@@ -1973,7 +1973,7 @@ rspamd_init_libs (void)
        struct ottery_config *ottery_cfg;
        gint ssl_options;
 
-       ctx = g_slice_alloc0 (sizeof (*ctx));
+       ctx = g_malloc0 (sizeof (*ctx));
        ctx->crypto_ctx = rspamd_cryptobox_init ();
        ottery_cfg = g_malloc0 (ottery_get_sizeof_config ());
        ottery_config_init (ottery_cfg);
@@ -2071,18 +2071,20 @@ rspamd_open_zstd_dictionary (const char *path)
 {
        struct zstd_dictionary *dict;
 
-       dict = g_slice_alloc0 (sizeof (*dict));
+       dict = g_malloc0 (sizeof (*dict));
        dict->dict = rspamd_file_xmap (path, PROT_READ, &dict->size, TRUE);
 
        if (dict->dict == NULL) {
-               g_slice_free1 (sizeof (*dict), dict);
+               g_free (dict);
+
                return NULL;
        }
 
        dict->id = ZDICT_getDictID (dict->dict, dict->size);
 
        if (dict->id == 0) {
-               g_slice_free1 (sizeof (*dict), dict);
+               g_free (dict);
+
                return NULL;
        }
 
@@ -2094,7 +2096,7 @@ rspamd_free_zstd_dictionary (struct zstd_dictionary *dict)
 {
        if (dict) {
                munmap (dict->dict, dict->size);
-               g_slice_free1 (sizeof (*dict), dict);
+               g_free (dict);
        }
 }
 
@@ -2250,7 +2252,7 @@ rspamd_deinit_libs (struct rspamd_external_libs_ctx *ctx)
                rspamd_free_zstd_dictionary (ctx->out_dict);
                ZSTD_freeCStream (ctx->out_zstream);
                ZSTD_freeDStream (ctx->in_zstream);
-               g_slice_free1 (sizeof (*ctx), ctx);
+               g_free (ctx);
        }
 }
 
index c21d69f33cca156bd390841f83b03553982d24df..9c5c3fde7b564d679414b1779847af5cb1eca222 100644 (file)
@@ -149,11 +149,11 @@ lua_redis_free_args (char **args, gsize *arglens, guint nargs)
 
        if (args) {
                for (i = 0; i < nargs; i ++) {
-                       g_slice_free1 (arglens[i], args[i]);
+                       g_free (args[i]);
                }
 
-               g_slice_free1 (sizeof (gchar *) * nargs, args);
-               g_slice_free1 (sizeof (gsize) * nargs, arglens);
+               g_free (args);
+               g_free (arglens);
        }
 }
 
@@ -194,7 +194,7 @@ lua_redis_dtor (struct lua_redis_ctx *ctx)
                                luaL_unref (ud->L, LUA_REGISTRYINDEX, cur->cbref);
                        }
 
-                       g_slice_free1 (sizeof (*cur), cur);
+                       g_free (cur);
                }
        }
        else {
@@ -203,7 +203,7 @@ lua_redis_dtor (struct lua_redis_ctx *ctx)
                }
        }
 
-       g_slice_free1 (sizeof (*ctx), ctx);
+       g_free (ctx);
 }
 
 static gint
@@ -478,10 +478,10 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
                        lua_pop (L, 1);
                }
 
-               args = g_slice_alloc ((top + 1) * sizeof (gchar *));
-               arglens = g_slice_alloc ((top + 1) * sizeof (gsize));
+               args = g_malloc ((top + 1) * sizeof (gchar *));
+               arglens = g_malloc ((top + 1) * sizeof (gsize));
                arglens[0] = strlen (cmd);
-               args[0] = g_slice_alloc (arglens[0]);
+               args[0] = g_malloc (arglens[0]);
                memcpy (args[0], cmd, arglens[0]);
                top = 1;
                lua_pushnil (L);
@@ -493,7 +493,7 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
                                const gchar *s;
 
                                s = lua_tolstring (L, -1, &arglens[top]);
-                               args[top] = g_slice_alloc (arglens[top]);
+                               args[top] = g_malloc (arglens[top]);
                                memcpy (args[top], s, arglens[top]);
                                top ++;
                        }
@@ -504,7 +504,7 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
 
                                if (t && t->start) {
                                        arglens[top] = t->len;
-                                       args[top] = g_slice_alloc (arglens[top]);
+                                       args[top] = g_malloc (arglens[top]);
                                        memcpy (args[top], t->start, arglens[top]);
                                        top ++;
                                }
@@ -524,7 +524,7 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
                                }
 
                                arglens[top] = r;
-                               args[top] = g_slice_alloc (arglens[top]);
+                               args[top] = g_malloc (arglens[top]);
                                memcpy (args[top], numbuf, arglens[top]);
                                top ++;
                        }
@@ -537,10 +537,10 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
        else {
                /* Use merely cmd */
 
-               args = g_slice_alloc (sizeof (gchar *));
-               arglens = g_slice_alloc (sizeof (gsize));
+               args = g_malloc (sizeof (gchar *));
+               arglens = g_malloc (sizeof (gsize));
                arglens[0] = strlen (cmd);
-               args[0] = g_slice_alloc (arglens[0]);
+               args[0] = g_malloc (arglens[0]);
                memcpy (args[0], cmd, arglens[0]);
                top = 1;
        }
@@ -677,7 +677,7 @@ rspamd_lua_redis_prepare_connection (lua_State *L, gint *pcbref)
 
 
                if (ret && addr != NULL) {
-                       ctx = g_slice_alloc0 (sizeof (struct lua_redis_ctx));
+                       ctx = g_malloc0 (sizeof (struct lua_redis_ctx));
                        REF_INIT_RETAIN (ctx, lua_redis_dtor);
                        ctx->flags |= flags | LUA_REDIS_ASYNC;
                        ud = &ctx->d.async;
@@ -764,7 +764,7 @@ lua_redis_make_request (lua_State *L)
 
        if (ctx) {
                ud = &ctx->d.async;
-               sp_ud = g_slice_alloc0 (sizeof (*sp_ud));
+               sp_ud = g_malloc0 (sizeof (*sp_ud));
                sp_ud->cbref = cbref;
                sp_ud->c = ud;
                sp_ud->ctx = ctx;
@@ -1083,7 +1083,7 @@ lua_redis_connect_sync (lua_State *L)
 
        if (ret) {
                double_to_tv (timeout, &tv);
-               ctx = g_slice_alloc0 (sizeof (struct lua_redis_ctx));
+               ctx = g_malloc0 (sizeof (struct lua_redis_ctx));
                REF_INIT_RETAIN (ctx, lua_redis_dtor);
                ctx->flags = flags;
                ctx->d.sync = redisConnectWithTimeout (
@@ -1169,7 +1169,7 @@ lua_redis_add_cmd (lua_State *L)
                                return luaL_error (L, "invalid arguments");
                        }
 
-                       sp_ud = g_slice_alloc0 (sizeof (*sp_ud));
+                       sp_ud = g_malloc0 (sizeof (*sp_ud));
                        sp_ud->cbref = cbref;
                        sp_ud->c = &ctx->d.async;
                        sp_ud->ctx = ctx;
index a35ec96b557628e55ead50e2eb794b599a1c1e09..1853e4a4dbc97e756d7d97c23c6c5f4e34430835 100644 (file)
@@ -141,7 +141,7 @@ lua_regexp_create (lua_State *L)
                g_error_free (err);
        }
        else {
-               new = g_slice_alloc0 (sizeof (struct rspamd_lua_regexp));
+               new = g_malloc0 (sizeof (struct rspamd_lua_regexp));
                new->re = re;
                new->re_pattern = g_strdup (string);
                new->module = rspamd_lua_get_module_name (L);
@@ -176,7 +176,7 @@ lua_regexp_get_cached (lua_State *L)
        re = rspamd_regexp_cache_query (NULL, string, flags_str);
 
        if (re) {
-               new = g_slice_alloc0 (sizeof (struct rspamd_lua_regexp));
+               new = g_malloc0 (sizeof (struct rspamd_lua_regexp));
                new->re = rspamd_regexp_ref (re);
                new->re_pattern = g_strdup (string);
                new->module = rspamd_lua_get_module_name (L);
@@ -222,7 +222,7 @@ lua_regexp_create_cached (lua_State *L)
        re = rspamd_regexp_cache_query (NULL, string, flags_str);
 
        if (re) {
-               new = g_slice_alloc0 (sizeof (struct rspamd_lua_regexp));
+               new = g_malloc0 (sizeof (struct rspamd_lua_regexp));
                new->re = rspamd_regexp_ref (re);
                new->re_pattern = g_strdup (string);
                new->module = rspamd_lua_get_module_name (L);
@@ -241,7 +241,7 @@ lua_regexp_create_cached (lua_State *L)
                        g_error_free (err);
                }
                else {
-                       new = g_slice_alloc0 (sizeof (struct rspamd_lua_regexp));
+                       new = g_malloc0 (sizeof (struct rspamd_lua_regexp));
                        new->re = rspamd_regexp_ref (re);
                        new->re_pattern = g_strdup (string);
                        new->module = rspamd_lua_get_module_name (L);
@@ -714,7 +714,7 @@ lua_regexp_gc (lua_State *L)
 
                g_free (to_del->re_pattern);
                g_free (to_del->module);
-               g_slice_free1 (sizeof (*to_del), to_del);
+               g_free (to_del);
        }
 
        return 0;
index 6e47e98a06e3c9e1d9e068d95a6d6bba8af99e1c..cd2dcc6e1080cc643b45f864424599bd66b9011b 100644 (file)
@@ -263,7 +263,7 @@ lua_tcp_shift_handler (struct lua_tcp_cbdata *cbd)
                }
        }
 
-       g_slice_free1 (sizeof (*hdl), hdl);
+       g_free (hdl);
 
        return TRUE;
 }
@@ -294,11 +294,11 @@ lua_tcp_fin (gpointer arg)
 
        LL_FOREACH_SAFE (cbd->dtors, dtor, dttmp) {
                dtor->dtor (dtor->data);
-               g_slice_free1 (sizeof (*dtor), dtor);
+               g_free (dtor);
        }
 
        g_byte_array_unref (cbd->in);
-       g_slice_free1 (sizeof (struct lua_tcp_cbdata), cbd);
+       g_free (cbd);
 }
 
 static struct lua_tcp_cbdata *
@@ -860,7 +860,7 @@ lua_tcp_arg_toiovec (lua_State *L, gint pos, struct lua_tcp_cbdata *cbd,
                        if (t->flags & RSPAMD_TEXT_FLAG_OWN) {
                                /* Steal ownership */
                                t->flags = 0;
-                               dtor = g_slice_alloc0 (sizeof (*dtor));
+                               dtor = g_malloc0 (sizeof (*dtor));
                                dtor->dtor = g_free;
                                dtor->data = (void *)t->start;
                                LL_PREPEND (cbd->dtors, dtor);
@@ -874,7 +874,7 @@ lua_tcp_arg_toiovec (lua_State *L, gint pos, struct lua_tcp_cbdata *cbd,
        else if (lua_type (L, pos) == LUA_TSTRING) {
                str = luaL_checklstring (L, pos, &len);
                vec->iov_base = g_malloc (len);
-               dtor = g_slice_alloc0 (sizeof (*dtor));
+               dtor = g_malloc0 (sizeof (*dtor));
                dtor->dtor = g_free;
                dtor->data = vec->iov_base;
                LL_PREPEND (cbd->dtors, dtor);
@@ -961,7 +961,7 @@ lua_tcp_request (lua_State *L)
                }
                cbref = luaL_ref (L, LUA_REGISTRYINDEX);
 
-               cbd = g_slice_alloc0 (sizeof (*cbd));
+               cbd = g_malloc0 (sizeof (*cbd));
 
                lua_pushstring (L, "task");
                lua_gettable (L, -2);
@@ -1081,7 +1081,7 @@ lua_tcp_request (lua_State *L)
                                msg_err ("tcp request has bad data argument");
                                lua_pushboolean (L, FALSE);
                                g_free (iov);
-                               g_slice_free1 (sizeof (*cbd), cbd);
+                               g_free (cbd);
 
                                return 1;
                        }
@@ -1106,7 +1106,7 @@ lua_tcp_request (lua_State *L)
                                        msg_err ("tcp request has bad data argument at pos %d", niov);
                                        lua_pushboolean (L, FALSE);
                                        g_free (iov);
-                                       g_slice_free1 (sizeof (*cbd), cbd);
+                                       g_free (cbd);
 
                                        return 1;
                                }
@@ -1135,7 +1135,7 @@ lua_tcp_request (lua_State *L)
        if (total_out > 0) {
                struct lua_tcp_handler *wh;
 
-               wh = g_slice_alloc0 (sizeof (*wh));
+               wh = g_malloc0 (sizeof (*wh));
                wh->type = LUA_WANT_WRITE;
                wh->h.w.iov = iov;
                wh->h.w.iovlen = niov;
@@ -1180,7 +1180,7 @@ lua_tcp_request (lua_State *L)
        if (do_read) {
                struct lua_tcp_handler *rh;
 
-               rh = g_slice_alloc0 (sizeof (*rh));
+               rh = g_malloc0 (sizeof (*rh));
                rh->type = LUA_WANT_READ;
                rh->h.r.cbref = cbref;
                rh->h.r.stop_pattern = stop_pattern;
@@ -1291,7 +1291,7 @@ lua_tcp_add_read (lua_State *L)
                }
        }
 
-       rh = g_slice_alloc0 (sizeof (*rh));
+       rh = g_malloc0 (sizeof (*rh));
        rh->type = LUA_WANT_READ;
        rh->h.r.cbref = cbref;
        rh->h.r.stop_pattern = stop_pattern;
@@ -1356,7 +1356,7 @@ lua_tcp_add_write (lua_State *L)
                                msg_err ("tcp request has bad data argument at pos %d", niov);
                                lua_pushboolean (L, FALSE);
                                g_free (iov);
-                               g_slice_free1 (sizeof (*cbd), cbd);
+                               g_free (cbd);
 
                                return 1;
                        }
@@ -1370,7 +1370,7 @@ lua_tcp_add_write (lua_State *L)
                lua_pop (L, 1);
        }
 
-       wh = g_slice_alloc0 (sizeof (*wh));
+       wh = g_malloc0 (sizeof (*wh));
        wh->type = LUA_WANT_WRITE;
        wh->h.w.iov = iov;
        wh->h.w.iovlen = niov;