Commit 43bf84df authored by Lubos Slovak's avatar Lubos Slovak

public-libs: Removed prefix from mempattern.

parent 501e50b8
......@@ -206,23 +206,23 @@ static void hhash_free_buckets(hhash_t *tbl)
hhash_t *hhash_create(uint32_t size)
{
knot_mm_ctx_t mm;
knot_mm_ctx_init(&mm);
mm_ctx_t mm;
mm_ctx_init(&mm);
return hhash_create_mm(size, &mm);
}
hhash_t *hhash_create_mm(uint32_t size, const knot_mm_ctx_t *mm)
hhash_t *hhash_create_mm(uint32_t size, const mm_ctx_t *mm)
{
if (size == 0) {
return NULL;
}
const size_t total_len = sizeof(hhash_t) + size * sizeof(hhelem_t);
hhash_t *tbl = knot_mm_alloc((knot_mm_ctx_t *)mm, total_len);
hhash_t *tbl = mm_alloc((mm_ctx_t *)mm, total_len);
if (tbl) {
memset(tbl, 0, total_len);
tbl->size = size;
memcpy(&tbl->mm, mm, sizeof(knot_mm_ctx_t));
memcpy(&tbl->mm, mm, sizeof(mm_ctx_t));
}
return tbl;
......
......@@ -63,7 +63,7 @@ typedef struct hhash {
uint32_t weight; /*!< Table weight (number of inserted). */
/* Table data storage. */
knot_mm_ctx_t mm; /*!< Memory manager. */
mm_ctx_t mm; /*!< Memory manager. */
uint32_t *index; /*!< Order index (optional). */
hhelem_t item[]; /*!< Table items. */
} hhash_t;
......@@ -78,7 +78,7 @@ typedef struct hhash {
hhash_t *hhash_create(uint32_t size);
/*! \brief Create hopscotch hash table (custom memory manager). */
hhash_t *hhash_create_mm(uint32_t size, const knot_mm_ctx_t *mm);
hhash_t *hhash_create_mm(uint32_t size, const mm_ctx_t *mm);
/*!
* \brief Clear hash table.
......
......@@ -183,9 +183,9 @@ size_t list_size(const list_t *l)
* @val: added pointer
* @mm: memory context
*/
ptrnode_t *ptrlist_add(list_t *to, const void *val, knot_mm_ctx_t *mm)
ptrnode_t *ptrlist_add(list_t *to, const void *val, mm_ctx_t *mm)
{
ptrnode_t *node = knot_mm_alloc(mm , sizeof(ptrnode_t));
ptrnode_t *node = mm_alloc(mm , sizeof(ptrnode_t));
if (node == NULL) {
return NULL;
} else {
......@@ -200,11 +200,11 @@ ptrnode_t *ptrlist_add(list_t *to, const void *val, knot_mm_ctx_t *mm)
* @list: list nodes
* @mm: memory context
*/
void ptrlist_free(list_t *list, knot_mm_ctx_t *mm)
void ptrlist_free(list_t *list, mm_ctx_t *mm)
{
node_t *n = NULL, *nxt = NULL;
WALK_LIST_DELSAFE(n, nxt, *list) {
knot_mm_free(mm, n);
mm_free(mm, n);
}
init_list(list);
}
......
......@@ -92,8 +92,8 @@ typedef struct ptrnode {
const void *d;
} ptrnode_t;
ptrnode_t *ptrlist_add(list_t *, const void *, knot_mm_ctx_t *);
void ptrlist_free(list_t *, knot_mm_ctx_t *);
ptrnode_t *ptrlist_add(list_t *, const void *, mm_ctx_t *);
void ptrlist_free(list_t *, mm_ctx_t *);
bool ptrlist_contains(list_t *, const void *);
/*! \todo This is broken atm.
......
......@@ -18,8 +18,6 @@
#include "common/mempattern.h"
#include "common/mempool.h"
/*! \todo Define the _public_ macro also in common/ */
#include "libknot/common.h"
static void mm_nofree(void *p)
{
......@@ -32,8 +30,7 @@ static void *mm_malloc(void *ctx, size_t n)
return malloc(n);
}
_public_
void *knot_mm_alloc(knot_mm_ctx_t *mm, size_t size)
void *mm_alloc(mm_ctx_t *mm, size_t size)
{
if (mm) {
return mm->alloc(mm->ctx, size);
......@@ -43,8 +40,7 @@ void *knot_mm_alloc(knot_mm_ctx_t *mm, size_t size)
}
_public_
void *knot_mm_realloc(knot_mm_ctx_t *mm, void *what, size_t size, size_t prev_size)
void *mm_realloc(mm_ctx_t *mm, void *what, size_t size, size_t prev_size)
{
if (mm) {
void *p = mm->alloc(mm->ctx, size);
......@@ -55,7 +51,7 @@ void *knot_mm_realloc(knot_mm_ctx_t *mm, void *what, size_t size, size_t prev_si
memcpy(p, what,
prev_size < size ? prev_size : size);
}
knot_mm_free(mm, what);
mm_free(mm, what);
return p;
}
} else {
......@@ -63,8 +59,7 @@ void *knot_mm_realloc(knot_mm_ctx_t *mm, void *what, size_t size, size_t prev_si
}
}
_public_
void knot_mm_free(knot_mm_ctx_t *mm, void *what)
void mm_free(mm_ctx_t *mm, void *what)
{
if (mm) {
if (mm->free) {
......@@ -75,18 +70,16 @@ void knot_mm_free(knot_mm_ctx_t *mm, void *what)
}
}
_public_
void knot_mm_ctx_init(knot_mm_ctx_t *mm)
void mm_ctx_init(mm_ctx_t *mm)
{
mm->ctx = NULL;
mm->alloc = mm_malloc;
mm->free = free;
}
_public_
void knot_mm_ctx_mempool(knot_mm_ctx_t *mm, size_t chunk_size)
void mm_ctx_mempool(mm_ctx_t *mm, size_t chunk_size)
{
mm->ctx = mp_new(chunk_size);
mm->alloc = (knot_mm_alloc_t)mp_alloc;
mm->alloc = (mm_alloc_t)mp_alloc;
mm->free = mm_nofree;
}
......@@ -32,28 +32,28 @@
#define MM_DEFAULT_BLKSIZE 4096
/* Memory allocation function prototypes. */
typedef void* (*knot_mm_alloc_t)(void* ctx, size_t len);
typedef void (*knot_mm_free_t)(void *p);
typedef void (*knot_mm_flush_t)(void *p);
typedef void* (*mm_alloc_t)(void* ctx, size_t len);
typedef void (*mm_free_t)(void *p);
typedef void (*mm_flush_t)(void *p);
/*! \brief Memory allocation context. */
typedef struct mm_ctx {
void *ctx; /* \note Must be first */
knot_mm_alloc_t alloc;
knot_mm_free_t free;
} knot_mm_ctx_t;
mm_alloc_t alloc;
mm_free_t free;
} mm_ctx_t;
/*! \brief Allocs using 'mm' if any, uses system malloc() otherwise. */
void *knot_mm_alloc(knot_mm_ctx_t *mm, size_t size);
void *mm_alloc(mm_ctx_t *mm, size_t size);
/*! \brief Reallocs using 'mm' if any, uses system realloc() otherwise. */
void *knot_mm_realloc(knot_mm_ctx_t *mm, void *what, size_t size, size_t prev_size);
void *mm_realloc(mm_ctx_t *mm, void *what, size_t size, size_t prev_size);
/*! \brief Free using 'mm' if any, uses system free() otherwise. */
void knot_mm_free(knot_mm_ctx_t *mm, void *what);
void mm_free(mm_ctx_t *mm, void *what);
/*! \brief Initialize default memory allocation context. */
void knot_mm_ctx_init(knot_mm_ctx_t *mm);
void mm_ctx_init(mm_ctx_t *mm);
/*! \brief Memory pool context. */
void knot_mm_ctx_mempool(knot_mm_ctx_t *mm, size_t chunk_size);
void mm_ctx_mempool(mm_ctx_t *mm, size_t chunk_size);
/*! @} */
......@@ -44,7 +44,7 @@ struct namedb_api {
/* Context operations */
int (*init)(const char *config, knot_namedb_t **db, knot_mm_ctx_t *mm);
int (*init)(const char *config, knot_namedb_t **db, mm_ctx_t *mm);
void (*deinit)(knot_namedb_t *db);
/* Transactions */
......
......@@ -20,7 +20,7 @@
#include "common/trie/hat-trie.h"
#include "common/mempattern.h"
static int init(const char *config, knot_namedb_t **db, knot_mm_ctx_t *mm)
static int init(const char *config, knot_namedb_t **db, mm_ctx_t *mm)
{
if (config != NULL || db == NULL) {
return KNOT_EINVAL;
......
......@@ -54,7 +54,7 @@ struct hattrie_t_
node_ptr root; // root node
size_t m; // number of stored keys
unsigned bsize; // bucket size
knot_mm_ctx_t mm;
mm_ctx_t mm;
};
/* Create an empty trie node. */
......@@ -279,7 +279,7 @@ static void hattrie_initroot(hattrie_t *T)
}
/* Free hat-trie nodes recursively. */
static void hattrie_free_node(node_ptr node, knot_mm_free_t free_cb)
static void hattrie_free_node(node_ptr node, mm_free_t free_cb)
{
if (*node.flag & NODE_TYPE_TRIE) {
size_t i;
......@@ -317,8 +317,8 @@ static void hattrie_deinit(hattrie_t * T)
hattrie_t* hattrie_create()
{
knot_mm_ctx_t mm;
knot_mm_ctx_init(&mm);
mm_ctx_t mm;
mm_ctx_init(&mm);
return hattrie_create_n(TRIE_BUCKET_SIZE, &mm);
}
......@@ -373,10 +373,10 @@ size_t hattrie_weight (const hattrie_t *T)
return T->m;
}
hattrie_t* hattrie_create_n(unsigned bucket_size, const knot_mm_ctx_t *mm)
hattrie_t* hattrie_create_n(unsigned bucket_size, const mm_ctx_t *mm)
{
hattrie_t* T = knot_mm_alloc((knot_mm_ctx_t *)mm, sizeof(hattrie_t));
memcpy(&T->mm, mm, sizeof(knot_mm_ctx_t));
hattrie_t* T = mm_alloc((mm_ctx_t *)mm, sizeof(hattrie_t));
memcpy(&T->mm, mm, sizeof(mm_ctx_t));
hattrie_init(T, bucket_size);
return T;
}
......
......@@ -44,7 +44,7 @@ size_t hattrie_weight (const hattrie_t*); //< Number of entries
/** Create new trie with custom bucket size and memory management.
*/
hattrie_t* hattrie_create_n (unsigned, const knot_mm_ctx_t *);
hattrie_t* hattrie_create_n (unsigned, const mm_ctx_t *);
/** Duplicate an existing trie.
*/
......
......@@ -747,7 +747,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
/* Init malloc wrapper for trie size estimation. */
size_t malloc_size = 0;
knot_mm_ctx_t mem_ctx = { .ctx = &malloc_size,
mm_ctx_t mem_ctx = { .ctx = &malloc_size,
.alloc = estimator_malloc,
.free = estimator_free };
......
......@@ -333,7 +333,7 @@ int synth_record_load(struct query_plan *plan, struct query_module *self)
}
/* Create synthesis template. */
struct synth_template *tpl = knot_mm_alloc(self->mm, sizeof(struct synth_template));
struct synth_template *tpl = mm_alloc(self->mm, sizeof(struct synth_template));
if (tpl == NULL) {
return KNOT_ENOMEM;
}
......@@ -405,6 +405,6 @@ int synth_record_load(struct query_plan *plan, struct query_module *self)
int synth_record_unload(struct query_module *self)
{
knot_mm_free(self->mm, self->ctx);
mm_free(self->mm, self->ctx);
return KNOT_EOK;
}
......@@ -97,7 +97,7 @@ static void axfr_query_cleanup(struct query_data *qdata)
hattrie_iter_free(axfr->i);
ptrlist_free(&axfr->proc.nodes, qdata->mm);
knot_mm_free(qdata->mm, axfr);
mm_free(qdata->mm, axfr);
/* Allow zone changes (finished). */
rcu_read_unlock();
......@@ -129,10 +129,10 @@ static int axfr_query_init(struct query_data *qdata)
}
/* Create transfer processing context. */
knot_mm_ctx_t *mm = qdata->mm;
mm_ctx_t *mm = qdata->mm;
zone_contents_t *zone = qdata->zone->contents;
struct axfr_proc *axfr = knot_mm_alloc(mm, sizeof(struct axfr_proc));
struct axfr_proc *axfr = mm_alloc(mm, sizeof(struct axfr_proc));
if (axfr == NULL) {
return KNOT_ENOMEM;
}
......@@ -166,7 +166,7 @@ int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb process_item,
}
int ret = KNOT_EOK;
knot_mm_ctx_t *mm = qdata->mm;
mm_ctx_t *mm = qdata->mm;
struct xfr_proc *xfer = qdata->ext;
zone_contents_t *zone = qdata->zone->contents;
......@@ -187,7 +187,7 @@ int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb process_item,
if (ret == KNOT_EOK) { /* Finished. */
/* Complete change set. */
rem_node((node_t *)head);
knot_mm_free(mm, head);
mm_free(mm, head);
} else { /* Packet full or other error. */
break;
}
......@@ -269,7 +269,7 @@ static void axfr_answer_cleanup(struct answer_data *data)
struct xfr_proc *proc = data->ext;
if (proc) {
zone_contents_deep_free(&proc->contents);
knot_mm_free(data->mm, proc);
mm_free(data->mm, proc);
data->ext = NULL;
}
}
......@@ -286,7 +286,7 @@ static int axfr_answer_init(struct answer_data *data)
}
/* Create new processing context. */
struct xfr_proc *proc = knot_mm_alloc(data->mm, sizeof(struct xfr_proc));
struct xfr_proc *proc = mm_alloc(data->mm, sizeof(struct xfr_proc));
if (proc == NULL) {
zone_contents_deep_free(&new_contents);
return KNOT_ENOMEM;
......
......@@ -55,7 +55,7 @@ static const char *get_txt_response_string(const knot_dname_t *qname)
* \return KNOT_EOK
*/
static int create_txt_rrset(knot_rrset_t *rrset, const knot_dname_t *owner,
const char *response, knot_mm_ctx_t *mm)
const char *response, mm_ctx_t *mm)
{
// truncate response to one TXT label
size_t response_len = strlen(response);
......
......@@ -49,8 +49,8 @@ static int wildcard_visit(struct query_data *qdata, const zone_node_t *node, con
return KNOT_EOK;
}
knot_mm_ctx_t *mm = qdata->mm;
struct wildcard_hit *item = knot_mm_alloc(mm, sizeof(struct wildcard_hit));
mm_ctx_t *mm = qdata->mm;
struct wildcard_hit *item = mm_alloc(mm, sizeof(struct wildcard_hit));
item->node = node;
item->sname = sname;
add_tail(&qdata->wildcards, (node_t *)item);
......@@ -61,7 +61,7 @@ static int wildcard_visit(struct query_data *qdata, const zone_node_t *node, con
static int dname_cname_synth(const knot_rrset_t *dname_rr,
const knot_dname_t *qname,
knot_rrset_t *cname_rrset,
knot_mm_ctx_t *mm)
mm_ctx_t *mm)
{
if (cname_rrset == NULL) {
return KNOT_EINVAL;
......@@ -143,7 +143,7 @@ static int put_rrsig(const knot_dname_t *sig_owner, uint16_t type,
}
/* Create rrsig info structure. */
struct rrsig_info *info = knot_mm_alloc(qdata->mm, sizeof(struct rrsig_info));
struct rrsig_info *info = mm_alloc(qdata->mm, sizeof(struct rrsig_info));
if (info == NULL) {
knot_rdataset_clear(&synth_rrs, qdata->mm);
return KNOT_ENOMEM;
......@@ -152,7 +152,7 @@ static int put_rrsig(const knot_dname_t *sig_owner, uint16_t type,
/* Store RRSIG into info structure. */
knot_dname_t *owner_copy = knot_dname_copy(sig_owner, qdata->mm);
if (owner_copy == NULL) {
knot_mm_free(qdata->mm, info);
mm_free(qdata->mm, info);
knot_rdataset_clear(&synth_rrs, qdata->mm);
return KNOT_ENOMEM;
}
......
......@@ -47,7 +47,7 @@ struct ixfr_proc {
list_t changesets; /* Processed changesets. */
size_t change_count; /* Count of changesets received. */
zone_t *zone; /* Modified zone - for journal access. */
knot_mm_ctx_t *mm; /* Memory context for RR allocations. */
mm_ctx_t *mm; /* Memory context for RR allocations. */
struct query_data *qdata;
const knot_rrset_t *soa_from;
const knot_rrset_t *soa_to;
......@@ -213,12 +213,12 @@ static int ixfr_query_check(struct query_data *qdata)
static void ixfr_answer_cleanup(struct query_data *qdata)
{
struct ixfr_proc *ixfr = (struct ixfr_proc *)qdata->ext;
knot_mm_ctx_t *mm = qdata->mm;
mm_ctx_t *mm = qdata->mm;
ptrlist_free(&ixfr->proc.nodes, mm);
changeset_iter_clear(&ixfr->cur);
changesets_free(&ixfr->changesets);
knot_mm_free(mm, qdata->ext);
mm_free(mm, qdata->ext);
/* Allow zone changes (finished). */
rcu_read_unlock();
......@@ -248,8 +248,8 @@ static int ixfr_answer_init(struct query_data *qdata)
}
/* Initialize transfer processing. */
knot_mm_ctx_t *mm = qdata->mm;
struct ixfr_proc *xfer = knot_mm_alloc(mm, sizeof(struct ixfr_proc));
mm_ctx_t *mm = qdata->mm;
struct ixfr_proc *xfer = mm_alloc(mm, sizeof(struct ixfr_proc));
if (xfer == NULL) {
changesets_free(&chgsets);
return KNOT_ENOMEM;
......@@ -346,7 +346,7 @@ static void ixfrin_cleanup(struct answer_data *data)
if (proc) {
changesets_free(&proc->changesets);
knot_rrset_free(&proc->final_soa, proc->mm);
knot_mm_free(data->mm, proc);
mm_free(data->mm, proc);
data->ext = NULL;
}
}
......@@ -354,7 +354,7 @@ static void ixfrin_cleanup(struct answer_data *data)
/*! \brief Initializes IXFR-in processing context. */
static int ixfrin_answer_init(struct answer_data *data)
{
struct ixfr_proc *proc = knot_mm_alloc(data->mm, sizeof(struct ixfr_proc));
struct ixfr_proc *proc = mm_alloc(data->mm, sizeof(struct ixfr_proc));
if (proc == NULL) {
return KNOT_ENOMEM;
}
......@@ -459,7 +459,7 @@ static int solve_soa_del(const knot_rrset_t *rr, struct ixfr_proc *proc)
}
/*! \brief Stores ending SOA into changeset. */
static int solve_soa_add(const knot_rrset_t *rr, changeset_t *change, knot_mm_ctx_t *mm)
static int solve_soa_add(const knot_rrset_t *rr, changeset_t *change, mm_ctx_t *mm)
{
assert(rr->type == KNOT_RRTYPE_SOA);
change->soa_to = knot_rrset_copy(rr, NULL);
......@@ -471,13 +471,13 @@ static int solve_soa_add(const knot_rrset_t *rr, changeset_t *change, knot_mm_ct
}
/*! \brief Adds single RR into remove section of changeset. */
static int solve_del(const knot_rrset_t *rr, changeset_t *change, knot_mm_ctx_t *mm)
static int solve_del(const knot_rrset_t *rr, changeset_t *change, mm_ctx_t *mm)
{
return changeset_rem_rrset(change, rr);
}
/*! \brief Adds single RR into add section of changeset. */
static int solve_add(const knot_rrset_t *rr, changeset_t *change, knot_mm_ctx_t *mm)
static int solve_add(const knot_rrset_t *rr, changeset_t *change, mm_ctx_t *mm)
{
return changeset_add_rrset(change, rr);
}
......
......@@ -49,7 +49,7 @@ static int process_answer_begin(knot_layer_t *ctx, void *module_param)
/* Initialize context. */
assert(ctx);
ctx->type = KNOT_NS_PROC_ANSWER_ID;
ctx->data = knot_mm_alloc(ctx->mm, sizeof(struct answer_data));
ctx->data = mm_alloc(ctx->mm, sizeof(struct answer_data));
/* Initialize persistent data. */
answer_data_init(ctx, module_param);
......@@ -81,7 +81,7 @@ static int process_answer_reset(knot_layer_t *ctx)
static int process_answer_finish(knot_layer_t *ctx)
{
process_answer_reset(ctx);
knot_mm_free(ctx->mm, ctx->data);
mm_free(ctx->mm, ctx->data);
ctx->data = NULL;
return KNOT_NS_PROC_NOOP;
......
......@@ -61,7 +61,7 @@ struct answer_data {
/* Everything below should be kept on reset. */
int response_type; /*!< Type of incoming response. */
struct process_answer_param *param; /*!< Module parameters. */
knot_mm_ctx_t *mm; /*!< Memory context. */
mm_ctx_t *mm; /*!< Memory context. */
};
/*! @} */
......@@ -39,7 +39,7 @@ static int process_query_begin(knot_layer_t *ctx, void *module_param)
/* Initialize context. */
assert(ctx);
ctx->type = NS_PROC_QUERY_ID;
ctx->data = knot_mm_alloc(ctx->mm, sizeof(struct query_data));
ctx->data = mm_alloc(ctx->mm, sizeof(struct query_data));
/* Initialize persistent data. */
query_data_init(ctx, module_param);
......@@ -74,7 +74,7 @@ static int process_query_reset(knot_layer_t *ctx)
static int process_query_finish(knot_layer_t *ctx)
{
process_query_reset(ctx);
knot_mm_free(ctx->mm, ctx->data);
mm_free(ctx->mm, ctx->data);
ctx->data = NULL;
return KNOT_NS_PROC_NOOP;
......
......@@ -94,7 +94,7 @@ struct query_data {
/* Everything below should be kept on reset. */
struct process_query_param *param; /*!< Module parameters. */
knot_mm_ctx_t *mm; /*!< Memory context. */
mm_ctx_t *mm; /*!< Memory context. */
};
/*! \brief Visited wildcard node list. */
......
......@@ -26,9 +26,9 @@ struct compiled_module MODULES[] = {
#define MODULE_COUNT sizeof(MODULES) / sizeof(MODULES[0])
struct query_plan *query_plan_create(knot_mm_ctx_t *mm)
struct query_plan *query_plan_create(mm_ctx_t *mm)
{
struct query_plan *plan = knot_mm_alloc(mm, sizeof(struct query_plan));
struct query_plan *plan = mm_alloc(mm, sizeof(struct query_plan));
if (plan == NULL) {
return NULL;
}
......@@ -50,16 +50,16 @@ void query_plan_free(struct query_plan *plan)
for (unsigned i = 0; i < QUERY_PLAN_STAGES; ++i) {
struct query_step *step = NULL, *next = NULL;
WALK_LIST_DELSAFE(step, next, plan->stage[i]) {
knot_mm_free(plan->mm, step);
mm_free(plan->mm, step);
}
}
knot_mm_free(plan->mm, plan);
mm_free(plan->mm, plan);
}
static struct query_step *make_step(knot_mm_ctx_t *mm, qmodule_process_t process, void *ctx)
static struct query_step *make_step(mm_ctx_t *mm, qmodule_process_t process, void *ctx)
{
struct query_step *step = knot_mm_alloc(mm, sizeof(struct query_step));
struct query_step *step = mm_alloc(mm, sizeof(struct query_step));
if (step == NULL) {
return NULL;
}
......@@ -82,7 +82,7 @@ int query_plan_step(struct query_plan *plan, int stage, qmodule_process_t proces
}
struct query_module *query_module_open(struct conf_t *config, const char *name,
const char *param, knot_mm_ctx_t *mm)
const char *param, mm_ctx_t *mm)
{
/* Locate compiled-in modules. */
struct compiled_module *found = NULL;
......@@ -98,7 +98,7 @@ struct query_module *query_module_open(struct conf_t *config, const char *name,
return NULL;
}
struct query_module *module = knot_mm_alloc(mm, sizeof(struct query_module));
struct query_module *module = mm_alloc(mm, sizeof(struct query_module));
if (module == NULL) {
return NULL;
}
......@@ -109,9 +109,9 @@ struct query_module *query_module_open(struct conf_t *config, const char *name,
module->config = config;
module->load = found->load;
module->unload = found->unload;
module->param = knot_mm_alloc(mm, buflen);
module->param = mm_alloc(mm, buflen);
if (module->param == NULL) {
knot_mm_free(mm, module);
mm_free(mm, module);
return NULL;
}
strlcpy(module->param, param, buflen);
......@@ -126,6 +126,6 @@ void query_module_close(struct query_module *module)
}
module->unload(module);
knot_mm_free(module->mm, module->param);
knot_mm_free(module->mm, module);
mm_free(module->mm, module->param);
mm_free(module->mm, module);
}
......@@ -77,7 +77,7 @@ struct query_module {
node_t node;
void *ctx;
char *param;
knot_mm_ctx_t *mm;
mm_ctx_t *mm;
struct conf_t *config;
qmodule_load_t load;
qmodule_unload_t unload;
......@@ -95,12 +95,12 @@ struct query_step {
* assembly phase, for example 'before processing', 'answer section' and so on.
*/
struct query_plan {
knot_mm_ctx_t *mm;
mm_ctx_t *mm;
list_t stage[QUERY_PLAN_STAGES];
};
/*! \brief Create an empty query plan. */
struct query_plan *query_plan_create(knot_mm_ctx_t *mm);
struct query_plan *query_plan_create(mm_ctx_t *mm);
/*! \brief Free query plan and all planned steps. */
void query_plan_free(struct query_plan *plan);
......@@ -113,7 +113,7 @@ int query_plan_step(struct query_plan *plan, int stage, qmodule_process_t proces
* \note Module 'load' hook is NOT called and left upon a caller to decide.
*/
struct query_module *query_module_open(struct conf_t *config, const char *name,
const char *param, knot_mm_ctx_t *mm);
const char *param, mm_ctx_t *mm);
/*!
* \brief Close query module.
......
......@@ -137,7 +137,7 @@ static int tcp_handle(tcp_context_t *tcp, int fd,
}
/* Create packets. */
knot_mm_ctx_t *mm = tcp->overlay.mm;
mm_ctx_t *mm = tcp->overlay.mm;
knot_pkt_t *ans = knot_pkt_new(tx->iov_base, tx->iov_len, mm);
knot_pkt_t *query = knot_pkt_new(rx->iov_base, rx->iov_len, mm);
......@@ -315,8 +315,8 @@ int tcp_master(dthread_t *thread)
memset(&tcp, 0, sizeof(tcp_context_t));
/* Create big enough memory cushion. */
knot_mm_ctx_t mm;
knot_mm_ctx_mempool(&mm, 4 * sizeof(knot_pkt_t));
mm_ctx_t mm;
mm_ctx_mempool(&mm, 4 * sizeof(knot_pkt_t));
/* Create TCP answering context. */
tcp.server = handler->server;
......
......@@ -133,7 +133,7 @@ void udp_handle(udp_context_t *udp, int fd, struct sockaddr_storage *ss,
}
/* Create packets. */
knot_mm_ctx_t *mm = udp->overlay.mm;
mm_ctx_t *mm = udp->overlay.mm;
knot_pkt_t *query = knot_pkt_new(rx->iov_base, rx->iov_len, mm);
knot_pkt_t *ans = knot_pkt_new(tx->iov_base, tx->iov_len, mm);
......@@ -507,8 +507,8 @@ int udp_master(dthread_t *thread)
udp.thread_id = handler->thread_id[thr_id];
/* Create big enough memory cushion. */
knot_mm_ctx_t mm;
knot_mm_ctx_mempool(&mm, 4 * sizeof(knot_pkt_t));
mm_ctx_t mm;
mm_ctx_mempool(&mm, 4 * sizeof(knot_pkt_t));
udp.overlay.mm = &mm;
/* Chose select as epoll/kqueue has larger overhead for a
......
......@@ -34,13 +34,13 @@
* Freed data:
* - actual data inside knot_rrs_t. (the rest is part of the node)
*/
static void rrs_list_clear(list_t *l, knot_mm_ctx_t *mm)
static void rrs_list_clear(list_t *l, mm_ctx_t *mm)
{
ptrnode_t *n;
node_t *nxt;
WALK_LIST_DELSAFE(n, nxt, *l) {
knot_mm_free(mm, (void *)n->d);
knot_mm_free(mm, n);
mm_free(mm, (void *)n->d);
mm_free(mm, n);
};
}
......
......@@ -19,7 +19,7 @@
#include "common/mempool.h"
static int add_to_node(zone_node_t *node, const zone_node_t *add_node,
knot_mm_ctx_t *mm)
mm_ctx_t *mm)
{
for (uint16_t i = 0; i < add_node->rrset_count; ++i) {
knot_rrset_t rr = node_rrset_at(add_node, i);
......@@ -35,7 +35,7 @@ static int add_to_node(zone_node_t *node, const zone_node_t *add_node,
}
static int rem_from_node(zone_node_t *node, const zone_node_t *rem_node,
knot_mm_ctx_t *mm)
mm_ctx_t *mm)
{
for (uint16_t i = 0; i < rem_node->rrset_count; ++i) {
// Remove each found RR from 'node'.
......@@ -56,7 +56,7 @@ static int rem_from_node(zone_node_t *node, const zone_node_t *rem_node,
}
static int apply_changes_to_node(zone_node_t *synth_node, const zone_node_t *add_node,
const zone_node_t *rem_node, knot_mm_ctx_t *mm)
const zone_node_t *rem_node, mm_ctx_t *mm)