Commit feb3f648 authored by Marek Vavruša's avatar Marek Vavruša

contrib: use embedded ucw/mempool instead of libknot internals

parent 94588c7e
......@@ -19,6 +19,7 @@
#include <getopt.h>
#include <uv.h>
#include <libknot/internal/sockaddr.h>
#include <ucw/mempool.h>
#include "lib/defines.h"
#include "lib/resolve.h"
......@@ -128,8 +129,10 @@ int main(int argc, char **argv)
uv_signal_start(&sigint, signal_handler, SIGINT);
/* Create a server engine. */
mm_ctx_t pool;
mm_ctx_mempool(&pool, MM_DEFAULT_BLKSIZE);
mm_ctx_t pool = {
.ctx = mp_new (4096),
.alloc = (mm_alloc_t) mp_alloc
};
struct engine engine;
ret = engine_init(&engine, &pool);
if (ret != 0) {
......
......@@ -17,7 +17,7 @@
#include <uv.h>
#include <libknot/packet/pkt.h>
#include <libknot/internal/net.h>
#include <libknot/internal/mempool.h>
#include <ucw/mempool.h>
#include "daemon/worker.h"
#include "daemon/engine.h"
......@@ -62,8 +62,10 @@ static int parse_query(knot_pkt_t *query)
static struct qr_task *qr_task_create(struct worker_ctx *worker, uv_handle_t *handle, knot_pkt_t *query, const struct sockaddr *addr)
{
mm_ctx_t pool;
mm_ctx_mempool(&pool, MM_DEFAULT_BLKSIZE);
mm_ctx_t pool = {
.ctx = mp_new (4096),
.alloc = (mm_alloc_t) mp_alloc
};
/* Create worker task */
struct engine *engine = worker->engine;
......
ccan_EMBED := \
contrib/ccan/ilog/ilog.c \
contrib/ccan/isaac/isaac.c \
contrib/ucw/mempool.c \
contrib/murmurhash3/murmurhash3.c
libkres_SOURCES := \
......
......@@ -16,12 +16,10 @@
#include <stdio.h>
#include <fcntl.h>
#include <libknot/internal/mempool.h>
#include <libknot/rrtype/rdname.h>
#include <libknot/descriptor.h>
#include <libknot/internal/net.h>
#include <ucw/mempool.h>
#include "lib/resolve.h"
#include "lib/layer.h"
#include "lib/rplan.h"
......@@ -265,8 +263,10 @@ int kr_resolve(struct kr_context* ctx, knot_pkt_t *answer,
}
/* Create memory pool */
mm_ctx_t pool;
mm_ctx_mempool(&pool, MM_DEFAULT_BLKSIZE);
mm_ctx_t pool = {
.ctx = mp_new (KNOT_WIRE_MAX_PKTSIZE),
.alloc = (mm_alloc_t) mp_alloc
};
knot_pkt_t *query = knot_pkt_new(NULL, KNOT_EDNS_MAX_UDP_PAYLOAD, &pool);
knot_pkt_t *resp = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, &pool);
if (!query || !resp) {
......
......@@ -59,8 +59,12 @@
* @code{.c}
*
* // Create request and its memory pool
* struct kr_request req;
* mm_ctx_mempool(&req.pool, 4096);
* struct kr_request req = {
* .pool = {
* .ctx = mp_new (4096),
* .alloc = (mm_alloc_t) mp_alloc
* }
* };
* kr_resolve_begin(&req, ctx, answer);
* int state = kr_resolve_query(&req, qname, qclass, qtype);
*
......
......@@ -21,12 +21,12 @@
* The module provides an override for queried address records.
*/
#include <ccan/json/json.h>
#include <libknot/packet/pkt.h>
#include <libknot/descriptor.h>
#include <libknot/internal/lists.h>
#include <libknot/internal/mempool.h>
#include <libknot/rrtype/aaaa.h>
#include <ccan/json/json.h>
#include <ucw/mempool.h>
#include "lib/layer/iterate.h"
#include "lib/zonecut.h"
......@@ -171,8 +171,10 @@ static int load(struct kr_module *module, const char *path)
}
/* Create pool and copy itself */
mm_ctx_t _pool;
mm_ctx_mempool(&_pool, MM_DEFAULT_BLKSIZE);
mm_ctx_t _pool = {
.ctx = mp_new(4096),
.alloc = (mm_alloc_t) mp_alloc
};
mm_ctx_t *pool = mm_alloc(&_pool, sizeof(*pool));
if (!pool) {
return kr_error(ENOMEM);
......
......@@ -14,8 +14,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libknot/internal/mempool.h>
#include <libknot/internal/namedb/namedb_lmdb.h>
#include <ucw/mempool.h>
#include "tests/test.h"
#include "lib/cache.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment