Commit 5f1f66cf authored by Lubos Slovak's avatar Lubos Slovak

public-libs: Prefixed mempattern + visibility

parent e8599597
......@@ -206,23 +206,23 @@ static void hhash_free_buckets(hhash_t *tbl)
hhash_t *hhash_create(uint32_t size)
{
mm_ctx_t mm;
mm_ctx_init(&mm);
knot_mm_ctx_t mm;
knot_mm_ctx_init(&mm);
return hhash_create_mm(size, &mm);
}
hhash_t *hhash_create_mm(uint32_t size, const mm_ctx_t *mm)
hhash_t *hhash_create_mm(uint32_t size, const knot_mm_ctx_t *mm)
{
if (size == 0) {
return NULL;
}
const size_t total_len = sizeof(hhash_t) + size * sizeof(hhelem_t);
hhash_t *tbl = mm_alloc((mm_ctx_t *)mm, total_len);
hhash_t *tbl = knot_mm_alloc((knot_mm_ctx_t *)mm, total_len);
if (tbl) {
memset(tbl, 0, total_len);
tbl->size = size;
memcpy(&tbl->mm, mm, sizeof(mm_ctx_t));
memcpy(&tbl->mm, mm, sizeof(knot_mm_ctx_t));
}
return tbl;
......
......@@ -63,7 +63,7 @@ typedef struct hhash {
uint32_t weight; /*!< Table weight (number of inserted). */
/* Table data storage. */
mm_ctx_t mm; /*!< Memory manager. */
knot_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 mm_ctx_t *mm);
hhash_t *hhash_create_mm(uint32_t size, const knot_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, mm_ctx_t *mm)
ptrnode_t *ptrlist_add(list_t *to, const void *val, knot_mm_ctx_t *mm)
{
ptrnode_t *node = mm_alloc(mm , sizeof(ptrnode_t));
ptrnode_t *node = knot_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, mm_ctx_t *mm)
* @list: list nodes
* @mm: memory context
*/
void ptrlist_free(list_t *list, mm_ctx_t *mm)
void ptrlist_free(list_t *list, knot_mm_ctx_t *mm)
{
node_t *n = NULL, *nxt = NULL;
WALK_LIST_DELSAFE(n, nxt, *list) {
mm_free(mm, n);
knot_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 *, mm_ctx_t *);
void ptrlist_free(list_t *, mm_ctx_t *);
ptrnode_t *ptrlist_add(list_t *, const void *, knot_mm_ctx_t *);
void ptrlist_free(list_t *, knot_mm_ctx_t *);
bool ptrlist_contains(list_t *, const void *);
/*! \todo This is broken atm.
......
......@@ -54,7 +54,7 @@ struct hattrie_t_
node_ptr root; // root node
size_t m; // number of stored keys
unsigned bsize; // bucket size
mm_ctx_t mm;
knot_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, mm_free_t free_cb)
static void hattrie_free_node(node_ptr node, knot_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()
{
mm_ctx_t mm;
mm_ctx_init(&mm);
knot_mm_ctx_t mm;
knot_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 mm_ctx_t *mm)
hattrie_t* hattrie_create_n(unsigned bucket_size, const knot_mm_ctx_t *mm)
{
hattrie_t* T = mm_alloc((mm_ctx_t *)mm, sizeof(hattrie_t));
memcpy(&T->mm, mm, sizeof(mm_ctx_t));
hattrie_t* T = knot_mm_alloc((knot_mm_ctx_t *)mm, sizeof(hattrie_t));
memcpy(&T->mm, mm, sizeof(knot_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 mm_ctx_t *);
hattrie_t* hattrie_create_n (unsigned, const knot_mm_ctx_t *);
/** Duplicate an existing trie.
*/
......
......@@ -753,7 +753,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
/* Init malloc wrapper for trie size estimation. */
size_t malloc_size = 0;
mm_ctx_t mem_ctx = { .ctx = &malloc_size,
knot_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 = mm_alloc(self->mm, sizeof(struct synth_template));
struct synth_template *tpl = knot_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)
{
mm_free(self->mm, self->ctx);
knot_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);
mm_free(qdata->mm, axfr);
knot_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. */
mm_ctx_t *mm = qdata->mm;
knot_mm_ctx_t *mm = qdata->mm;
zone_contents_t *zone = qdata->zone->contents;
struct axfr_proc *axfr = mm_alloc(mm, sizeof(struct axfr_proc));
struct axfr_proc *axfr = knot_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;
mm_ctx_t *mm = qdata->mm;
knot_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);
mm_free(mm, head);
knot_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);
mm_free(data->mm, proc);
knot_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 = mm_alloc(data->mm, sizeof(struct xfr_proc));
struct xfr_proc *proc = knot_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, mm_ctx_t *mm)
const char *response, knot_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;
}
mm_ctx_t *mm = qdata->mm;
struct wildcard_hit *item = mm_alloc(mm, sizeof(struct wildcard_hit));
knot_mm_ctx_t *mm = qdata->mm;
struct wildcard_hit *item = knot_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,
mm_ctx_t *mm)
knot_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 = mm_alloc(qdata->mm, sizeof(struct rrsig_info));
struct rrsig_info *info = knot_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) {
mm_free(qdata->mm, info);
knot_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. */
mm_ctx_t *mm; /* Memory context for RR allocations. */
knot_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;
mm_ctx_t *mm = qdata->mm;
knot_mm_ctx_t *mm = qdata->mm;
ptrlist_free(&ixfr->proc.nodes, mm);
changeset_iter_clear(&ixfr->cur);
changesets_free(&ixfr->changesets);
mm_free(mm, qdata->ext);
knot_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. */
mm_ctx_t *mm = qdata->mm;
struct ixfr_proc *xfer = mm_alloc(mm, sizeof(struct ixfr_proc));
knot_mm_ctx_t *mm = qdata->mm;
struct ixfr_proc *xfer = knot_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);
mm_free(data->mm, proc);
knot_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 = mm_alloc(data->mm, sizeof(struct ixfr_proc));
struct ixfr_proc *proc = knot_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, mm_ctx_t *mm)
static int solve_soa_add(const knot_rrset_t *rr, changeset_t *change, knot_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, mm_ctx_t *
}
/*! \brief Adds single RR into remove section of changeset. */
static int solve_del(const knot_rrset_t *rr, changeset_t *change, mm_ctx_t *mm)
static int solve_del(const knot_rrset_t *rr, changeset_t *change, knot_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, mm_ctx_t *mm)
static int solve_add(const knot_rrset_t *rr, changeset_t *change, knot_mm_ctx_t *mm)
{
return changeset_add_rrset(change, rr);
}
......
......@@ -47,7 +47,7 @@ static int process_answer_begin(knot_layer_t *ctx, void *module_param)
/* Initialize context. */
assert(ctx);
ctx->type = NS_PROC_ANSWER_ID;
ctx->data = mm_alloc(ctx->mm, sizeof(struct answer_data));
ctx->data = knot_mm_alloc(ctx->mm, sizeof(struct answer_data));
/* Initialize persistent data. */
answer_data_init(ctx, module_param);
......@@ -79,7 +79,7 @@ static int process_answer_reset(knot_layer_t *ctx)
static int process_answer_finish(knot_layer_t *ctx)
{
process_answer_reset(ctx);
mm_free(ctx->mm, ctx->data);
knot_mm_free(ctx->mm, ctx->data);
ctx->data = NULL;
return NS_PROC_NOOP;
......
......@@ -60,7 +60,7 @@ struct answer_data {
/* Everything below should be kept on reset. */
struct process_answer_param *param; /*!< Module parameters. */
mm_ctx_t *mm; /*!< Memory context. */
knot_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 = mm_alloc(ctx->mm, sizeof(struct query_data));
ctx->data = knot_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);
mm_free(ctx->mm, ctx->data);
knot_mm_free(ctx->mm, ctx->data);
ctx->data = NULL;
return NS_PROC_NOOP;
......
......@@ -94,7 +94,7 @@ struct query_data {
/* Everything below should be kept on reset. */
struct process_query_param *param; /*!< Module parameters. */
mm_ctx_t *mm; /*!< Memory context. */
knot_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(mm_ctx_t *mm)
struct query_plan *query_plan_create(knot_mm_ctx_t *mm)
{
struct query_plan *plan = mm_alloc(mm, sizeof(struct query_plan));
struct query_plan *plan = knot_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]) {
mm_free(plan->mm, step);
knot_mm_free(plan->mm, step);
}
}
mm_free(plan->mm, plan);
knot_mm_free(plan->mm, plan);
}
static struct query_step *make_step(mm_ctx_t *mm, qmodule_process_t process, void *ctx)
static struct query_step *make_step(knot_mm_ctx_t *mm, qmodule_process_t process, void *ctx)
{
struct query_step *step = mm_alloc(mm, sizeof(struct query_step));
struct query_step *step = knot_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, mm_ctx_t *mm)
const char *param, knot_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 = mm_alloc(mm, sizeof(struct query_module));
struct query_module *module = knot_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 = mm_alloc(mm, buflen);
module->param = knot_mm_alloc(mm, buflen);
if (module->param == NULL) {
mm_free(mm, module);
knot_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);
mm_free(module->mm, module->param);
mm_free(module->mm, module);
knot_mm_free(module->mm, module->param);
knot_mm_free(module->mm, module);
}
......@@ -77,7 +77,7 @@ struct query_module {
node_t node;
void *ctx;
char *param;
mm_ctx_t *mm;
knot_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 {
mm_ctx_t *mm;
knot_mm_ctx_t *mm;
list_t stage[QUERY_PLAN_STAGES];
};
/*! \brief Create an empty query plan. */
struct query_plan *query_plan_create(mm_ctx_t *mm);
struct query_plan *query_plan_create(knot_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, mm_ctx_t *mm);
const char *param, knot_mm_ctx_t *mm);
/*!
* \brief Close query module.
......
......@@ -135,7 +135,7 @@ static int tcp_handle(tcp_context_t *tcp, int fd,
}
/* Create packets. */
mm_ctx_t *mm = tcp->overlay.mm;
knot_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);
......@@ -313,8 +313,8 @@ int tcp_master(dthread_t *thread)
memset(&tcp, 0, sizeof(tcp_context_t));
/* Create big enough memory cushion. */
mm_ctx_t mm;
mm_ctx_mempool(&mm, 4 * sizeof(knot_pkt_t));
knot_mm_ctx_t mm;
knot_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. */
mm_ctx_t *mm = udp->overlay.mm;
knot_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);
......@@ -509,8 +509,8 @@ int udp_master(dthread_t *thread)
udp.thread_id = handler->thread_id[thr_id];
/* Create big enough memory cushion. */
mm_ctx_t mm;
mm_ctx_mempool(&mm, 4 * sizeof(knot_pkt_t));
knot_mm_ctx_t mm;
knot_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, mm_ctx_t *mm)
static void rrs_list_clear(list_t *l, knot_mm_ctx_t *mm)
{
ptrnode_t *n;
node_t *nxt;
WALK_LIST_DELSAFE(n, nxt, *l) {
mm_free(mm, (void *)n->d);
mm_free(mm, n);
knot_mm_free(mm, (void *)n->d);
knot_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,
mm_ctx_t *mm)
knot_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,
mm_ctx_t *mm)
knot_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, mm_ctx_t *mm)
const zone_node_t *rem_node, knot_mm_ctx_t *mm)
{
// Add changes to node
if (!node_empty(add_node)) {
......@@ -78,7 +78,7 @@ static int apply_changes_to_node(zone_node_t *synth_node, const zone_node_t *add
}
static int deep_copy_node_data(zone_node_t *node_copy, const zone_node_t *node,
mm_ctx_t *mm)
knot_mm_ctx_t *mm)
{
// Clear space for RRs
node_copy->rrs = NULL;
......@@ -95,7 +95,7 @@ static int deep_copy_node_data(zone_node_t *node_copy, const zone_node_t *node,
return KNOT_EOK;
}
static zone_node_t *node_deep_copy(const zone_node_t *node, mm_ctx_t *mm)
static zone_node_t *node_deep_copy(const zone_node_t *node, knot_mm_ctx_t *mm)
{
// Shallow copy old node
zone_node_t *synth_node = node_shallow_copy(node, mm);
......@@ -119,7 +119,7 @@ void zone_update_init(zone_update_t *update, const zone_contents_t *zone, change
{
update->zone = zone;
update->change = change;
mm_ctx_mempool(&update->mm, 4096);
knot_mm_ctx_mempool(&update->mm, 4096);
}
const zone_node_t *zone_update_get_node(zone_update_t *update, const knot_dname_t *dname)
......
......@@ -34,7 +34,7 @@
typedef struct {
const zone_contents_t *zone; /*!< Zone being updated. */
changeset_t *change; /*!< Changes we want to apply. */
mm_ctx_t mm; /*!< Memory context used for intermediate nodes. */
knot_mm_ctx_t mm; /*!< Memory context used for intermediate nodes. */
} zone_update_t;
/*!
......
......@@ -25,7 +25,7 @@ void worker_queue_init(worker_queue_t *queue)
memset(queue, 0, sizeof(worker_queue_t));
init_list(&queue->list);
mm_ctx_init(&queue->mm_ctx);
knot_mm_ctx_init(&queue->mm_ctx);
}
void worker_queue_deinit(worker_queue_t *queue)
......
......@@ -33,7 +33,7 @@ typedef struct task {
* \brief Worker queue.
*/
typedef struct worker_queue {
mm_ctx_t mm_ctx;
knot_mm_ctx_t mm_ctx;
list_t list;
} worker_queue_t;
......
......@@ -68,7 +68,7 @@ static uint32_t bootstrap_next(uint32_t timer)
NS_PROC_LOG(severity, &remote->addr, zone->name, operation, msg)
/*! \brief Create zone query packet. */
static knot_pkt_t *zone_query(const zone_t *zone, uint16_t pkt_type, mm_ctx_t *mm)
static knot_pkt_t *zone_query(const zone_t *zone, uint16_t pkt_type, knot_mm_ctx_t *mm)
{
/* Determine query type and opcode. */
uint16_t query_type = KNOT_RRTYPE_SOA;
......@@ -114,8 +114,8 @@ static int zone_query_execute(zone_t *zone, uint16_t pkt_type, const conf_iface_
{
/* Create a memory pool for this task. */
int ret = KNOT_EOK;
mm_ctx_t mm;
mm_ctx_mempool(&mm, MM_DEFAULT_BLKSIZE);
knot_mm_ctx_t mm;
knot_mm_ctx_mempool(&mm, MM_DEFAULT_BLKSIZE);
/* Create a query message. */
knot_pkt_t *query = zone_query(zone, pkt_type, &mm);
......
......@@ -26,14 +26,14 @@
#include "libknot/mempattern.h"
/*! \brief Clears allocated data in RRSet entry. */
static void rr_data_clear(struct rr_data *data, mm_ctx_t *mm)
static void rr_data_clear(struct rr_data *data, knot_mm_ctx_t *mm)
{
knot_rdataset_clear(&data->rrs, mm);
free(data->additional);
}
/*! \brief Clears allocated data in RRSet entry. */
static int rr_data_from(const knot_rrset_t *rrset, struct rr_data *data, mm_ctx_t *mm)
static int rr_data_from(const knot_rrset_t *rrset, struct rr_data *data, knot_mm_ctx_t *mm)
{
int ret = knot_rdataset_copy(&data->rrs, &rrset->rrs, mm);
if (ret != KNOT_EOK) {
......@@ -47,7 +47,7 @@ static int rr_data_from(const knot_rrset_t *rrset, struct rr_data *data, mm_ctx_
/*! \brief Adds RRSet to node directly. */
static int add_rrset_no_merge(zone_node_t *node, const knot_rrset_t *rrset,
mm_ctx_t *mm)
knot_mm_ctx_t *mm)
{
if (node == NULL) {
return KNOT_EINVAL;
......@@ -55,7 +55,7 @@ static int add_rrset_no_merge(zone_node_t *node, const knot_rrset_t *rrset,
const size_t prev_nlen = node->rrset_count * sizeof(struct rr_data);
const size_t nlen = (node->rrset_count + 1) * sizeof(struct rr_data);
void *p = mm_realloc(mm, node->rrs, nlen, prev_nlen);
void *p = knot_mm_realloc(mm, node->rrs, nlen, prev_nlen);
if (p == NULL) {
return KNOT_ENOMEM;
}
......@@ -84,9 +84,9 @@ static bool ttl_error(struct rr_data *node_data, const knot_rrset_t *rrset)
return inserted_ttl != node_ttl;
}
zone_node_t *node_new(const knot_dname_t *owner, mm_ctx_t *mm)
zone_node_t *node_new(const knot_dname_t *owner, knot_mm_ctx_t *mm)
{
zone_node_t *ret = mm_alloc(mm, sizeof(zone_node_t));
zone_node_t *ret = knot_mm_alloc(mm, sizeof(zone_node_t));
if (ret == NULL) {
ERR_ALLOC_FAILED;
return NULL;
......@@ -96,7 +96,7 @@ zone_node_t *node_new(const knot_dname_t *owner, mm_ctx_t *mm)
if (owner) {
ret->owner = knot_dname_copy(owner, mm);