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 */
g_free (re->pattern);
}
- g_slice_free1 (sizeof (*re), re);
+ g_free (re);
}
}
}
/* 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;
{
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);
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");
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;
}
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;
}
g_free (file->filename);
g_free (file->id);
- g_slice_free1 (sizeof (struct rspamd_rrd_file), file);
+ g_free (file);
return 0;
}
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);
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 */
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);
}
/* 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) {
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;
}
g_queue_free (ctx->upstreams);
rspamd_mempool_delete (ctx->pool);
- g_slice_free1 (sizeof (*ctx), ctx);
+ g_free (ctx);
}
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;
struct upstream_addr_elt *elt = a;
rspamd_inet_address_free (elt->addr);
- g_slice_free1 (sizeof (*elt), elt);
+ g_free (elt);
}
static void
/* 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);
{
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 ();
REF_RELEASE (up->ctx);
}
- g_slice_free1 (sizeof (*up), up);
+ g_free (up);
}
rspamd_inet_addr_t*
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:
}
if (!ret) {
- g_slice_free1 (sizeof (*up), up);
+ g_free (up);
return FALSE;
}
else {
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);
g_ptr_array_free (ups->ups, TRUE);
rspamd_mutex_free (ups->lock);
- g_slice_free1 (sizeof (*ups), ups);
+ g_free (ups);
}
}
{
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
#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 {
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);
{
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;
}
{
if (dict) {
munmap (dict->dict, dict->size);
- g_slice_free1 (sizeof (*dict), dict);
+ g_free (dict);
}
}
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);
}
}
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);
}
}
luaL_unref (ud->L, LUA_REGISTRYINDEX, cur->cbref);
}
- g_slice_free1 (sizeof (*cur), cur);
+ g_free (cur);
}
}
else {
}
}
- g_slice_free1 (sizeof (*ctx), ctx);
+ g_free (ctx);
}
static gint
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);
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 ++;
}
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 ++;
}
}
arglens[top] = r;
- args[top] = g_slice_alloc (arglens[top]);
+ args[top] = g_malloc (arglens[top]);
memcpy (args[top], numbuf, arglens[top]);
top ++;
}
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;
}
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;
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;
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 (
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;
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);
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);
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);
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);
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;
}
}
- g_slice_free1 (sizeof (*hdl), hdl);
+ g_free (hdl);
return TRUE;
}
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 *
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);
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);
}
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);
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;
}
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;
}
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;
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;
}
}
- 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;
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;
}
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;