aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-27 11:21:40 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-27 11:21:40 +0100
commitc54eeafdd296585c1bd5100a58a36e3f32d03e78 (patch)
tree95db447670cca2e0bd81133f2a73d64183801678
parenta0d34edd00b42849901865e0a96b6a96f256bb80 (diff)
downloadrspamd-c54eeafdd296585c1bd5100a58a36e3f32d03e78.tar.gz
rspamd-c54eeafdd296585c1bd5100a58a36e3f32d03e78.zip
[Fix] Stop using of g_slice...
-rw-r--r--src/controller.c14
-rw-r--r--src/fuzzy_storage.c40
-rw-r--r--src/libserver/task.c4
-rw-r--r--src/libserver/worker_util.c4
-rw-r--r--src/libutil/mem_pool.c10
-rw-r--r--src/rspamd.c10
-rw-r--r--src/rspamd_proxy.c6
-rw-r--r--src/worker.c2
8 files changed, 45 insertions, 45 deletions
diff --git a/src/controller.c b/src/controller.c
index 9e015cb6d..f2b25f2f5 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1365,7 +1365,7 @@ rspamd_controller_handle_legacy_history (
top = ucl_object_typed_new (UCL_ARRAY);
/* Set lock on history */
- copied_rows = g_slice_alloc (sizeof (*copied_rows) * ctx->srv->history->nrows);
+ copied_rows = g_malloc (sizeof (*copied_rows) * ctx->srv->history->nrows);
memcpy (copied_rows, ctx->srv->history->rows,
sizeof (*copied_rows) * ctx->srv->history->nrows);
@@ -1434,6 +1434,7 @@ rspamd_controller_handle_legacy_history (
rspamd_controller_send_ucl (conn_ent, top);
ucl_object_unref (top);
+ g_free (copied_rows);
}
static gboolean
@@ -3008,7 +3009,7 @@ rspamd_controller_finish_handler (struct rspamd_http_connection_entry *conn_ent)
rspamd_mempool_delete (session->pool);
}
- g_slice_free1 (sizeof (struct rspamd_controller_session), session);
+ g_free (session);
}
static void
@@ -3032,7 +3033,7 @@ rspamd_controller_accept_socket (gint fd, short what, void *arg)
return;
}
- session = g_slice_alloc0 (sizeof (struct rspamd_controller_session));
+ session = g_malloc0 (sizeof (struct rspamd_controller_session));
session->pool = rspamd_mempool_new (rspamd_mempool_suggest_size (),
"csession");
session->ctx = ctx;
@@ -3507,6 +3508,7 @@ rspamd_plugin_cbdata_dtor (gpointer p)
g_free (cbd->plugin);
ucl_object_unref (cbd->obj); /* This also releases lua references */
+ g_free (cbd);
}
static void
@@ -3521,7 +3523,7 @@ rspamd_controller_register_plugin_path (lua_State *L,
const ucl_object_t *elt;
GString *full_path;
- cbd = g_slice_alloc0 (sizeof (*cbd));
+ cbd = g_malloc0 (sizeof (*cbd));
cbd->L = L;
cbd->ctx = ctx;
cbd->handler = ucl_object_toclosure (handler);
@@ -3536,7 +3538,7 @@ rspamd_controller_register_plugin_path (lua_State *L,
elt = ucl_object_lookup (webui_data, "enable");
- if (elt && !!ucl_object_toboolean (elt)) {
+ if (elt && ucl_object_toboolean (elt)) {
cbd->is_enable = TRUE;
}
@@ -3655,7 +3657,7 @@ start_controller_worker (struct rspamd_worker *worker)
ctx->rrd = rspamd_rrd_file_default (ctx->cfg->rrd_file, &rrd_err);
if (ctx->rrd) {
- ctx->rrd_event = g_slice_alloc0 (sizeof (*ctx->rrd_event));
+ ctx->rrd_event = g_malloc0 (sizeof (*ctx->rrd_event));
evtimer_set (ctx->rrd_event, rspamd_controller_rrd_update, ctx);
event_base_set (ctx->ev_base, ctx->rrd_event);
event_add (ctx->rrd_event, &rrd_update_time);
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index ef26032a8..4d5706eb9 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -296,7 +296,7 @@ fuzzy_mirror_close_connection (struct fuzzy_slave_connection *conn)
close (conn->sock);
- g_slice_free1 (sizeof (*conn), conn);
+ g_free (conn);
}
}
@@ -326,7 +326,7 @@ fuzzy_mirror_updates_version_cb (guint64 rev64, void *ud)
ctx = cbdata->ctx;
msg = cbdata->msg;
m = cbdata->m;
- g_slice_free1 (sizeof (*cbdata), cbdata);
+ g_free (cbdata);
rev32 = GUINT32_TO_LE (rev32);
len = sizeof (guint32) * 2; /* revision + last chunk */
@@ -386,7 +386,7 @@ fuzzy_mirror_updates_to_http (struct rspamd_fuzzy_mirror *m,
struct rspamd_fuzzy_updates_cbdata *cbdata;
- cbdata = g_slice_alloc (sizeof (*cbdata));
+ cbdata = g_malloc (sizeof (*cbdata));
cbdata->ctx = ctx;
cbdata->msg = msg;
cbdata->conn = conn;
@@ -427,7 +427,7 @@ rspamd_fuzzy_send_update_mirror (struct rspamd_fuzzy_storage_ctx *ctx,
struct fuzzy_slave_connection *conn;
struct rspamd_http_message *msg;
- conn = g_slice_alloc0 (sizeof (*conn));
+ conn = g_malloc0 (sizeof (*conn));
conn->up = rspamd_upstream_get (m->u,
RSPAMD_UPSTREAM_MASTER_SLAVE, NULL, 0);
conn->mirror = m;
@@ -552,7 +552,7 @@ rspamd_fuzzy_updates_cb (gboolean success, void *ud)
}
g_free (cbdata->source);
- g_slice_free1 (sizeof (*cbdata), cbdata);
+ g_free (cbdata);
}
static void
@@ -563,7 +563,7 @@ rspamd_fuzzy_process_updates_queue (struct rspamd_fuzzy_storage_ctx *ctx,
struct rspamd_updates_cbdata *cbdata;
if ((forced ||ctx->updates_pending->len > 0)) {
- cbdata = g_slice_alloc (sizeof (*cbdata));
+ cbdata = g_malloc (sizeof (*cbdata));
cbdata->ctx = ctx;
cbdata->source = g_strdup (source);
rspamd_fuzzy_backend_process_updates (ctx->backend, ctx->updates_pending,
@@ -629,7 +629,7 @@ fuzzy_peer_send_io (gint fd, gshort what, gpointer d)
}
event_del (&up_req->io_ev);
- g_slice_free1 (sizeof (*up_req), up_req);
+ g_free (up_req);
}
static void
@@ -817,7 +817,7 @@ rspamd_fuzzy_process_command (struct fuzzy_session *session)
if (ip_stat == NULL) {
naddr = rspamd_inet_address_copy (session->addr);
- ip_stat = g_slice_alloc0 (sizeof (*ip_stat));
+ ip_stat = g_malloc0 (sizeof (*ip_stat));
rspamd_lru_hash_insert (session->key_stat->last_ips,
naddr, ip_stat, -1, 0);
}
@@ -881,7 +881,7 @@ rspamd_fuzzy_process_command (struct fuzzy_session *session)
}
else {
/* We need to send request to the peer */
- up_req = g_slice_alloc0 (sizeof (*up_req));
+ up_req = g_malloc0 (sizeof (*up_req));
up_req->cmd.is_shingle = is_shingle;
ptr = is_shingle ?
(gpointer)&up_req->cmd.cmd.shingle :
@@ -1234,7 +1234,7 @@ fuzzy_session_destroy (gpointer d)
rspamd_inet_address_free (session->addr);
rspamd_explicit_memzero (session->nm, sizeof (session->nm));
session->worker->nconns--;
- g_slice_free1 (sizeof (*session), session);
+ g_free (session);
}
static void
@@ -1249,7 +1249,7 @@ rspamd_fuzzy_mirror_session_destroy (struct fuzzy_master_update_session *session
if (session->psrc) {
g_free (session->psrc);
}
- g_slice_free1 (sizeof (*session), session);
+ g_free (session);
}
}
@@ -1389,9 +1389,7 @@ rspamd_fuzzy_collection_finish_handler (struct rspamd_http_connection_entry *con
rspamd_inet_address_free (session->from_addr);
-
-
- g_slice_free1 (sizeof (struct rspamd_fuzzy_collection_session), session);
+ g_free (session);
}
void
@@ -1605,7 +1603,7 @@ accept_fuzzy_collection_socket (gint fd, short what, void *arg)
return;
}
- session = g_slice_alloc0 (sizeof (*session));
+ session = g_malloc0 (sizeof (*session));
session->ctx = ctx;
session->worker = worker;
rspamd_random_hex (session->uid, sizeof (session->uid) - 1);
@@ -1700,7 +1698,7 @@ accept_fuzzy_mirror_socket (gint fd, short what, void *arg)
return;
}
- session = g_slice_alloc0 (sizeof (*session));
+ session = g_malloc0 (sizeof (*session));
session->name = rspamd_inet_address_to_string (addr);
rspamd_random_hex (session->uid, sizeof (session->uid) - 1);
session->uid[sizeof (session->uid) - 1] = '\0';
@@ -1765,7 +1763,7 @@ accept_fuzzy_socket (gint fd, short what, void *arg)
return;
}
- session = g_slice_alloc0 (sizeof (*session));
+ session = g_malloc0 (sizeof (*session));
REF_INIT_RETAIN (session, fuzzy_session_destroy);
session->worker = worker;
session->fd = fd;
@@ -2146,7 +2144,7 @@ fuzzy_storage_parse_mirror (rspamd_mempool_t *pool,
return FALSE;
}
- up = g_slice_alloc0 (sizeof (*up));
+ up = g_malloc0 (sizeof (*up));
up->name = g_strdup (ucl_object_tostring (elt));
elt = ucl_object_lookup (obj, "key");
@@ -2191,7 +2189,7 @@ err:
rspamd_pubkey_unref (up->key);
}
- g_slice_free1 (sizeof (*up), up);
+ g_free (up);
return FALSE;
}
@@ -2607,7 +2605,7 @@ fuzzy_peer_rep (struct rspamd_worker *worker,
if (ls->fd != -1) {
if (ls->type == RSPAMD_WORKER_SOCKET_UDP) {
- accept_events = g_slice_alloc0 (sizeof (struct event) * 2);
+ accept_events = g_malloc0 (sizeof (struct event) * 2);
event_set (&accept_events[0], ls->fd, EV_READ | EV_PERSIST,
accept_fuzzy_socket, worker);
event_base_set (ctx->ev_base, &accept_events[0]);
@@ -2617,7 +2615,7 @@ fuzzy_peer_rep (struct rspamd_worker *worker,
}
else if (worker->index == 0) {
/* We allow TCP listeners only for a update worker */
- accept_events = g_slice_alloc0 (sizeof (struct event) * 2);
+ accept_events = g_malloc0 (sizeof (struct event) * 2);
if (ctx->collection_mode) {
event_set (&accept_events[0], ls->fd, EV_READ | EV_PERSIST,
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 8bb8ecaa0..f4fcd8fb1 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -65,7 +65,7 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
{
struct rspamd_task *new_task;
- new_task = g_slice_alloc0 (sizeof (struct rspamd_task));
+ new_task = g_malloc0 (sizeof (struct rspamd_task));
new_task->worker = worker;
if (cfg) {
@@ -307,7 +307,7 @@ rspamd_task_free (struct rspamd_task *task)
rspamd_mempool_delete (task->task_pool);
}
- g_slice_free1 (sizeof (struct rspamd_task), task);
+ g_free (task);
}
}
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 38e58aa83..2ce4aaded 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -321,7 +321,7 @@ rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
ls = cur->data;
if (ls->fd != -1) {
- accept_events = g_slice_alloc0 (sizeof (struct event) * 2);
+ accept_events = g_malloc0 (sizeof (struct event) * 2);
event_set (&accept_events[0], ls->fd, EV_READ | EV_PERSIST,
accept_handler, worker);
event_base_set (ev_base, &accept_events[0]);
@@ -358,7 +358,7 @@ rspamd_worker_stop_accept (struct rspamd_worker *worker)
}
cur = g_list_next (cur);
- g_slice_free1 (sizeof (struct event) * 2, events);
+ g_free (events);
}
if (worker->accept_events != NULL) {
diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c
index 8f595c1ee..c9ca42934 100644
--- a/src/libutil/mem_pool.c
+++ b/src/libutil/mem_pool.c
@@ -201,7 +201,7 @@ rspamd_mempool_chain_new (gsize size, enum rspamd_mempool_chain_type pool_type)
g_atomic_int_add (&mem_pool_stat->bytes_allocated, size);
}
else {
- map = g_slice_alloc (sizeof (struct _pool_chain) + size);
+ map = g_malloc (sizeof (struct _pool_chain) + size);
chain = map;
chain->begin = ((guint8 *) chain) + sizeof (struct _pool_chain);
g_atomic_int_add (&mem_pool_stat->bytes_allocated, size);
@@ -340,7 +340,7 @@ rspamd_mempool_new_ (gsize size, const gchar *tag, const gchar *loc)
env_checked = TRUE;
}
- new = g_slice_alloc0 (sizeof (rspamd_mempool_t));
+ new = g_malloc0 (sizeof (rspamd_mempool_t));
new->entry = rspamd_mempool_get_entry (loc);
new->destructors = g_array_sized_new (FALSE, FALSE,
sizeof (struct _pool_destructors), 32);
@@ -683,7 +683,7 @@ rspamd_mempool_delete (rspamd_mempool_t * pool)
munmap ((void *)cur, len);
}
else {
- g_slice_free1 (len, cur);
+ g_free (cur);
}
}
@@ -706,7 +706,7 @@ rspamd_mempool_delete (rspamd_mempool_t * pool)
g_atomic_int_inc (&mem_pool_stat->pools_freed);
POOL_MTX_UNLOCK ();
- g_slice_free (rspamd_mempool_t, pool);
+ g_free (pool);
}
void
@@ -726,7 +726,7 @@ rspamd_mempool_cleanup_tmp (rspamd_mempool_t * pool)
g_atomic_int_add (&mem_pool_stat->chunks_allocated, -1);
len = cur->len + sizeof (struct _pool_chain);
- g_slice_free1 (len, cur);
+ g_free (cur);
}
g_ptr_array_free (pool->pools[RSPAMD_MEMPOOL_TMP], TRUE);
diff --git a/src/rspamd.c b/src/rspamd.c
index 1b24fd67a..d0ec042d8 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -325,7 +325,7 @@ rspamd_fork_delayed_cb (gint signo, short what, gpointer arg)
rspamd_fork_worker (w->rspamd_main, w->cf, w->oldindex,
w->rspamd_main->ev_base);
REF_RELEASE (w->cf);
- g_slice_free1 (sizeof (*w), w);
+ g_free (w);
}
static void
@@ -336,7 +336,7 @@ rspamd_fork_delayed (struct rspamd_worker_conf *cf,
struct waiting_worker *nw;
struct timeval tv;
- nw = g_slice_alloc0 (sizeof (*nw));
+ nw = g_malloc0 (sizeof (*nw));
nw->cf = cf;
nw->oldindex = index;
nw->rspamd_main = rspamd_main;
@@ -364,7 +364,7 @@ create_listen_socket (GPtrArray *addrs, guint cnt,
fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
SOCK_STREAM, TRUE);
if (fd != -1) {
- ls = g_slice_alloc0 (sizeof (*ls));
+ ls = g_malloc0 (sizeof (*ls));
ls->addr = g_ptr_array_index (addrs, i);
ls->fd = fd;
ls->type = RSPAMD_WORKER_SOCKET_TCP;
@@ -375,7 +375,7 @@ create_listen_socket (GPtrArray *addrs, guint cnt,
fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
SOCK_DGRAM, TRUE);
if (fd != -1) {
- ls = g_slice_alloc0 (sizeof (*ls));
+ ls = g_malloc0 (sizeof (*ls));
ls->addr = g_ptr_array_index (addrs, i);
ls->fd = fd;
ls->type = RSPAMD_WORKER_SOCKET_UDP;
@@ -436,7 +436,7 @@ systemd_get_socket (struct rspamd_main *rspamd_main, gint number)
return NULL;
}
- ls = g_slice_alloc0 (sizeof (*ls));
+ ls = g_malloc0 (sizeof (*ls));
ls->addr = rspamd_inet_address_from_sa (&addr_storage.sa, slen);
ls->fd = sock;
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index 5e00dca65..6223d32ef 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -1018,7 +1018,7 @@ proxy_session_dtor (struct rspamd_proxy_session *session)
rspamd_mempool_delete (session->pool);
}
- g_slice_free1 (sizeof (*session), session);
+ g_free (session);
}
static void
@@ -1131,7 +1131,7 @@ proxy_session_refresh (struct rspamd_proxy_session *session)
{
struct rspamd_proxy_session *nsession;
- nsession = g_slice_alloc0 (sizeof (*nsession));
+ nsession = g_malloc0 (sizeof (*nsession));
nsession->client_milter_conn = session->client_milter_conn;
session->client_milter_conn = NULL;
rspamd_milter_update_userdata (nsession->client_milter_conn,
@@ -1987,7 +1987,7 @@ proxy_accept_socket (gint fd, short what, void *arg)
return;
}
- session = g_slice_alloc0 (sizeof (*session));
+ session = g_malloc0 (sizeof (*session));
REF_INIT_RETAIN (session, proxy_session_dtor);
session->client_sock = nfd;
session->client_addr = addr;
diff --git a/src/worker.c b/src/worker.c
index 717e5451b..e001ec288 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -468,7 +468,7 @@ rspamd_worker_log_pipe_handler (struct rspamd_main *rspamd_main,
rep.type = RSPAMD_CONTROL_LOG_PIPE;
if (attached_fd != -1) {
- lp = g_slice_alloc0 (sizeof (*lp));
+ lp = g_malloc0 (sizeof (*lp));
lp->fd = attached_fd;
lp->type = cmd->cmd.log_pipe.type;