Commit 130796f6 authored by Vladimír Čunát's avatar Vladimír Čunát

Merge branch 'qp_trie_integration' into 'master'

QP trie integration

See !574. See original merge request !593 for more details.
parents 91742c48 52430205
......@@ -29,7 +29,6 @@ src/contrib/fnv/hash_64a.c
src/contrib/fnv/longlong.h
src/contrib/getline.c
src/contrib/getline.h
src/contrib/hat-trie/hat-trie.c
src/contrib/hat-trie/hat-trie.h
src/contrib/hhash.c
src/contrib/hhash.h
......@@ -50,6 +49,8 @@ src/contrib/openbsd/strlcpy.c
src/contrib/openbsd/strlcpy.h
src/contrib/print.c
src/contrib/print.h
src/contrib/qp-trie/qp.c
src/contrib/qp-trie/qp.h
src/contrib/sockaddr.c
src/contrib/sockaddr.h
src/contrib/string.c
......@@ -539,11 +540,11 @@ tests/confio.c
tests/contrib/test_base32hex.c
tests/contrib/test_base64.c
tests/contrib/test_endian.c
tests/contrib/test_hat-trie.c
tests/contrib/test_heap.c
tests/contrib/test_hhash.c
tests/contrib/test_net.c
tests/contrib/test_net_shortwrite.c
tests/contrib/test_qp-trie.c
tests/contrib/test_sockaddr.c
tests/contrib/test_string.c
tests/contrib/test_strtonum.c
......
......@@ -28,7 +28,6 @@ EXTRA_DIST = \
contrib/licenses/LGPL-2.0 \
contrib/licenses/MIT \
contrib/licenses/OLDAP-2.8 \
contrib/hat-trie/LICENSE \
contrib/lmdb/LICENSE \
contrib/murmurhash3/LICENSE \
contrib/openbsd/LICENSE \
......@@ -49,6 +48,7 @@ libcontrib_la_SOURCES = \
contrib/fnv/longlong.h \
contrib/getline.c \
contrib/getline.h \
contrib/hat-trie/hat-trie.h \
contrib/hhash.c \
contrib/hhash.h \
contrib/macros.h \
......@@ -58,6 +58,8 @@ libcontrib_la_SOURCES = \
contrib/net.h \
contrib/print.c \
contrib/print.h \
contrib/qp-trie/qp.c \
contrib/qp-trie/qp.h \
contrib/sockaddr.c \
contrib/sockaddr.h \
contrib/string.c \
......@@ -68,8 +70,6 @@ libcontrib_la_SOURCES = \
contrib/trim.h \
contrib/wire.h \
contrib/wire_ctx.h \
contrib/hat-trie/hat-trie.c \
contrib/hat-trie/hat-trie.h \
contrib/murmurhash3/murmurhash3.c \
contrib/murmurhash3/murmurhash3.h \
contrib/openbsd/strlcat.c \
......
../licenses/MIT
\ No newline at end of file
This diff is collapsed.
/*
* This file is part of hat-trie
*
* Copyright (c) 2011 by Daniel C. Jones <dcjones@cs.washington.edu>
*
* This is an ANSI C99 implementation of the HAT-trie data structure of Askitis
* and Sinha, an extremely efficient (space and time) modern variant of tries.
* The HAT-trie is in essence a hybrid data structure, combining tries and hash
* tables in a clever way to try to get the best of both worlds.
*
* The version implemented here maps arrays of bytes to words (i.e., unsigned
* longs), which can be used to store counts, pointers, etc, or not used at all if
* you simply want to maintain a set of unique strings.
*
* For details see
* 1. Askitis, N., & Sinha, R. (2007). HAT-trie: a cache-conscious trie-based data
* structure for strings. Proceedings of the thirtieth Australasian conference on
* Computer science-Volume 62 (pp. 97–105). Australian Computer Society, Inc.
* 2. Askitis, N., & Zobel, J. (2005). Cache-conscious collision resolution in
* string hash tables. String Processing and Information Retrieval (pp.
* 91–102). Springer.
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "contrib/qp-trie/qp.h"
#include <stdlib.h>
#include <stdbool.h>
typedef trie_t hattrie_t;
typedef trie_val_t value_t;
typedef trie_it_t hattrie_iter_t;
#include "contrib/hhash.h"
struct knot_mm;
inline static hattrie_t* hattrie_create(struct knot_mm *mm)
{
return trie_create(mm);
}
/* Hat-trie defines. */
#define TRIE_ZEROBUCKETS 0 /* Do not use hash buckets (pure trie). */
#define TRIE_BUCKET_SIZE 253 /* 253, 509, 765 for n*4K pages per 1 hhash. */
#define TRIE_BUCKET_INCR 256 /* Size increase. */
#define TRIE_BUCKET_MAX 4 /* Maximum N table increments. */
#define TRIE_MAXCHAR 0xff /* Use 7-bit ASCII alphabet. */
#define TRIE_EOK KNOT_EOK
inline static void hattrie_free(hattrie_t *trie)
{
trie_free(trie);
}
typedef struct hattrie_t_ hattrie_t;
inline static void hattrie_clear(hattrie_t *trie)
{
trie_clear(trie);
}
hattrie_t* hattrie_create (void); //< Create an empty hat-trie.
void hattrie_free (hattrie_t*); //< Free all memory used by a trie.
void hattrie_clear (hattrie_t*); //< Remove all entries.
size_t hattrie_weight (const hattrie_t*); //< Number of entries
inline static size_t hattrie_weight(const hattrie_t *trie)
{
return trie_weight(trie);
}
/** Create new trie with custom bucket size and memory management.
*/
hattrie_t* hattrie_create_n (unsigned, const struct knot_mm *);
inline static int hattrie_apply_rev(hattrie_t *trie, int (*f)(value_t*,void*), void* d)
{
return trie_apply(trie, f, d);
}
/** Duplicate an existing trie.
*/
hattrie_t* hattrie_dup (const hattrie_t*, value_t (*nval)(value_t));
inline static value_t* hattrie_tryget(hattrie_t *trie, const char *key, size_t len)
{
return trie_get_try(trie, key, len);
}
/** Build order index on all ahtable nodes in trie.
*/
void hattrie_build_index (hattrie_t*);
inline static value_t* hattrie_get(hattrie_t *trie, const char *key, size_t len)
{
return trie_get_ins(trie, key, len);
}
int hattrie_apply_rev (hattrie_t*, int (*f)(value_t*,void*), void* d);
int hattrie_apply_rev_ahtable(hattrie_t* T, int (*f)(void*,void*), void* d);
inline static int hattrie_find_leq(hattrie_t *trie, const char *key, size_t len, value_t **dst)
{
return trie_get_leq(trie, key, len, dst);
}
/** Find the given key in the trie, inserting it if it does not exist, and
* returning a pointer to its key.
*
* This pointer is not guaranteed to be valid after additional calls to
* hattrie_get, hattrie_del, hattrie_clear, or other functions that modifies the
* trie.
*/
value_t* hattrie_get (hattrie_t*, const char* key, size_t len);
inline static int hattrie_del(hattrie_t *trie, const char* key, size_t len, value_t *val)
{
return trie_del(trie, key, len, val);
}
/** Find a given key in the table, returning a NULL pointer if it does not
* exist. */
value_t* hattrie_tryget (hattrie_t*, const char* key, size_t len);
inline static hattrie_iter_t* hattrie_iter_begin(hattrie_t *trie)
{
return trie_it_begin(trie);
}
/** Find a given key in the table, returning a NULL pointer if it does not
* exist. Also set prev to point to previous node. */
int hattrie_find_leq (hattrie_t*, const char* key, size_t len, value_t** dst);
/** Find a next value for given key, returning NULL if it does not exist. */
int hattrie_find_next (hattrie_t* T, const char* key, size_t len, value_t **dst);
inline static void hattrie_iter_next(hattrie_iter_t *it)
{
trie_it_next(it);
}
/** Delete a given key from trie. Returns 0 if successful or -1 if not found.
*/
int hattrie_del(hattrie_t* T, const char* key, size_t len);
inline static bool hattrie_iter_finished(hattrie_iter_t *it)
{
return trie_it_finished(it);
}
typedef struct hattrie_iter_t_ hattrie_iter_t;
inline static void hattrie_iter_free(hattrie_iter_t *it)
{
trie_it_free(it);
}
hattrie_iter_t* hattrie_iter_begin (const hattrie_t*, bool sorted);
void hattrie_iter_next (hattrie_iter_t*);
bool hattrie_iter_finished (hattrie_iter_t*);
void hattrie_iter_free (hattrie_iter_t*);
const char* hattrie_iter_key (hattrie_iter_t*, size_t* len);
value_t* hattrie_iter_val (hattrie_iter_t*);
inline static const char* hattrie_iter_key(hattrie_iter_t *it, size_t *len)
{
return trie_it_key(it, len);
}
#ifdef __cplusplus
inline static value_t* hattrie_iter_val(hattrie_iter_t *it)
{
return trie_it_val(it);
}
#endif
This diff is collapsed.
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "libknot/mm_ctx.h"
/*!
* \file \brief Native API of QP-tries:
*
* - keys are char strings, not necessarily zero-terminated,
* the structure copies the contents of the passed keys
* - values are void* pointers, typically you get an ephemeral pointer to it
* - key lengths are limited by 2^32-1 ATM
*/
/*! \brief Element value. */
typedef void* trie_val_t;
/*! \brief Opaque structure holding a QP-trie. */
typedef struct trie trie_t;
/*! \brief Opaque type for holding a QP-trie iterator. */
typedef struct trie_it trie_it_t;
/*! \brief Create a trie instance. */
trie_t* trie_create(knot_mm_t *mm);
/*! \brief Free a trie instance. */
void trie_free(trie_t *tbl);
/*! \brief Clear a trie instance (make it empty). */
void trie_clear(trie_t *tbl);
/*! \brief Return the number of keys in the trie. */
size_t trie_weight(const trie_t *tbl);
/*! \brief Search the trie, returning NULL on failure. */
trie_val_t* trie_get_try(trie_t *tbl, const char *key, uint32_t len);
/*! \brief Search the trie, inserting NULL trie_val_t on failure. */
trie_val_t* trie_get_ins(trie_t *tbl, const char *key, uint32_t len);
/*!
* \brief Search for less-or-equal element.
*
* \param val must be valid; it will be set to NULL if not found or errored.
* \return KNOT_EOK for exact match, 1 for previous, KNOT_ENOENT for not-found,
* or KNOT_E*.
*/
int trie_get_leq(trie_t *tbl, const char *key, uint32_t len, trie_val_t **val);
/*!
* \brief Apply a function to every trie_val_t, in order.
*
* \return KNOT_EOK if success or KNOT_E* if error.
*/
int trie_apply(trie_t *tbl, int (*f)(trie_val_t *, void *), void *d);
/*!
* \brief Remove an item, returning KNOT_EOK if succeeded or KNOT_ENOENT if not found.
*
* If val!=NULL and deletion succeeded, the deleted value is set.
*/
int trie_del(trie_t *tbl, const char *key, uint32_t len, trie_val_t *val);
/*! \brief Create a new iterator pointing to the first element (if any). */
trie_it_t* trie_it_begin(trie_t *tbl);
/*!
* \brief Advance the iterator to the next element.
*
* Iteration is in ascending lexicographical order.
* In particular, the empty string would be considered as the very first.
*/
void trie_it_next(trie_it_t *it);
/*! \brief Test if the iterator has gone past the last element. */
bool trie_it_finished(trie_it_t *it);
/*! \brief Free any resources of the iterator. It's OK to call it on NULL. */
void trie_it_free(trie_it_t *it);
/*!
* \brief Return pointer to the key of the current element.
*
* \note The len is uint32_t internally but size_t is better for our usage
* as it is without an additional type conversion.
*/
const char* trie_it_key(trie_it_t *it, size_t *len);
/*! \brief Return pointer to the value of the current element (writable). */
trie_val_t* trie_it_val(trie_it_t *it);
......@@ -442,7 +442,7 @@ static int diff_zone_section(
return KNOT_EOK;
}
hattrie_iter_t *it = hattrie_iter_begin(conf()->io.zones, true);
hattrie_iter_t *it = hattrie_iter_begin(conf()->io.zones);
for (; !hattrie_iter_finished(it); hattrie_iter_next(it)) {
io->id = (const uint8_t *)hattrie_iter_key(it, &io->id_len);
......@@ -820,7 +820,7 @@ static void upd_changes(
// Prepare zone changes storage if it doesn't exist.
hattrie_t *zones = conf()->io.zones;
if (zones == NULL) {
zones = hattrie_create_n(TRIE_BUCKET_SIZE, conf()->mm);
zones = hattrie_create(conf()->mm);
if (zones == NULL) {
return;
}
......@@ -846,7 +846,7 @@ static void upd_changes(
case CONF_IO_TUNSET:
if (*current & CONF_IO_TSET) {
// Remove inserted zone -> no change.
hattrie_del(zones, (const char *)io->id, io->id_len);
hattrie_del(zones, (const char *)io->id, io->id_len, NULL);
} else {
// Remove existing zone.
*current |= type;
......@@ -1399,7 +1399,7 @@ static int check_zone_section(
return KNOT_EOK;
}
hattrie_iter_t *it = hattrie_iter_begin(conf()->io.zones, true);
hattrie_iter_t *it = hattrie_iter_begin(conf()->io.zones);
for (; !hattrie_iter_finished(it); hattrie_iter_next(it)) {
size_t id_len;
const uint8_t *id = (const uint8_t *)hattrie_iter_key(it, &id_len);
......
......@@ -548,7 +548,7 @@ static int zone_read(zone_t *zone, ctl_args_t *args)
ret = send_node((zone_node_t *)node, ctx);
} else if (zone->contents != NULL) {
ret = zone_contents_tree_apply_inorder(zone->contents, send_node, ctx);
ret = zone_contents_apply(zone->contents, send_node, ctx);
}
zone_read_failed:
......@@ -645,8 +645,7 @@ static int send_changeset_part(changeset_t *ch, send_ctx_t *ctx, bool from)
// Send other records.
changeset_iter_t it;
int ret = from ? changeset_iter_rem(&it, ch, true) :
changeset_iter_add(&it, ch, true);
int ret = from ? changeset_iter_rem(&it, ch) : changeset_iter_add(&it, ch);
if (ret != KNOT_EOK) {
return ret;
}
......
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -162,9 +162,7 @@ int knot_nsec_chain_iterate_create(zone_tree_t *nodes,
assert(nodes);
assert(callback);
bool sorted = true;
hattrie_iter_t *it = hattrie_iter_begin(nodes, sorted);
hattrie_iter_t *it = hattrie_iter_begin(nodes);
if (!it) {
return KNOT_ENOMEM;
}
......
......@@ -112,7 +112,7 @@ static int shallow_copy_signature(const zone_node_t *from, zone_node_t *to)
/*!
* \brief Reuse signatatures by shallow copying them from one tree to another.
*/
static int copy_signatures(const zone_tree_t *from, zone_tree_t *to)
static int copy_signatures(zone_tree_t *from, zone_tree_t *to)
{
if (zone_tree_is_empty(from)) {
return KNOT_EOK;
......@@ -120,8 +120,7 @@ static int copy_signatures(const zone_tree_t *from, zone_tree_t *to)
assert(to);
bool sorted = false;
hattrie_iter_t *it = hattrie_iter_begin(from, sorted);
hattrie_iter_t *it = hattrie_iter_begin(from);
for (/* NOP */; !hattrie_iter_finished(it); hattrie_iter_next(it)) {
zone_node_t *node_from = (zone_node_t *)*hattrie_iter_val(it);
......@@ -155,8 +154,7 @@ static void free_nsec3_tree(zone_tree_t *nodes)
{
assert(nodes);
bool sorted = false;
hattrie_iter_t *it = hattrie_iter_begin(nodes, sorted);
hattrie_iter_t *it = hattrie_iter_begin(nodes);
for (/* NOP */; !hattrie_iter_finished(it); hattrie_iter_next(it)) {
zone_node_t *node = (zone_node_t *)*hattrie_iter_val(it);
// newly allocated NSEC3 nodes
......@@ -430,8 +428,7 @@ static int create_nsec3_nodes(const zone_contents_t *zone,
int result = KNOT_EOK;
const bool sorted = false;
hattrie_iter_t *it = hattrie_iter_begin(zone->nodes, sorted);
hattrie_iter_t *it = hattrie_iter_begin(zone->nodes);
while (!hattrie_iter_finished(it)) {
zone_node_t *node = (zone_node_t *)*hattrie_iter_val(it);
......@@ -469,9 +466,6 @@ static int create_nsec3_nodes(const zone_contents_t *zone,
hattrie_iter_free(it);
/* Rebuild index over nsec3 nodes. */
hattrie_build_index(nsec3_nodes);
return result;
}
......
......@@ -97,7 +97,7 @@ static int mark_removed_nsec3(const zone_contents_t *zone, changeset_t *ch)
}
changeset_iter_t itt;
changeset_iter_rem(&itt, ch, false);
changeset_iter_rem(&itt, ch);
knot_rrset_t rr = changeset_iter_next(&itt);
while (!knot_rrset_empty(&rr)) {
......
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -1239,7 +1239,7 @@ int knot_zone_sign_changeset(const zone_contents_t *zone,
.zone_keys = zone_keys,
.dnssec_ctx = dnssec_ctx,
.changeset = out_ch,
.signed_tree = hattrie_create()
.signed_tree = hattrie_create(NULL)
};
if (args.signed_tree == NULL) {
......@@ -1247,7 +1247,7 @@ int knot_zone_sign_changeset(const zone_contents_t *zone,
}
changeset_iter_t itt;
changeset_iter_all(&itt, in_ch, false);
changeset_iter_all(&itt, in_ch);
knot_rrset_t rr = changeset_iter_next(&itt);
while (!knot_rrset_empty(&rr)) {
......@@ -1275,7 +1275,7 @@ int knot_zone_sign_nsecs_in_changeset(const zone_keyset_t *zone_keys,
}
changeset_iter_t itt;
changeset_iter_add(&itt, changeset, false);
changeset_iter_add(&itt, changeset);
knot_rrset_t rr = changeset_iter_next(&itt);
while (!knot_rrset_empty(&rr)) {
......
......@@ -70,7 +70,7 @@ static int axfr_process_node_tree(knot_pkt_t *pkt, const void *item,
struct axfr_proc *axfr = (struct axfr_proc*)state;
if (axfr->i == NULL) {
axfr->i = hattrie_iter_begin(item, true);
axfr->i = hattrie_iter_begin((hattrie_t *)item);
}
/* Put responses. */
......
......@@ -114,7 +114,7 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
/* Put REMOVE RRSets. */
if (ixfr->state == IXFR_DEL) {
if (iter_empty(ixfr)) {
ret = changeset_iter_rem(&ixfr->cur, chgset, false);
ret = changeset_iter_rem(&ixfr->cur, chgset);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -136,7 +136,7 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
/* Put Add RRSets. */
if (ixfr->state == IXFR_ADD) {
if (iter_empty(ixfr)) {
ret = changeset_iter_add(&ixfr->cur, chgset, false);
ret = changeset_iter_add(&ixfr->cur, chgset);
if (ret != KNOT_EOK) {
return ret;
}
......
......@@ -785,7 +785,7 @@ static int serialize_and_store_chgset(const changeset_t *chs,
}
changeset_iter_t itt;
ret = changeset_iter_rem(&itt, chs, false);
ret = changeset_iter_rem(&itt, chs);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -808,7 +808,7 @@ static int serialize_and_store_chgset(const changeset_t *chs,
}
/* Serialize RRSets from the 'add' section. */
ret = changeset_iter_add(&itt, chs, false);
ret = changeset_iter_add(&itt, chs);
if (ret != KNOT_EOK) {
return ret;
}
......
......@@ -78,7 +78,7 @@ int changeset_binary_size(const changeset_t *chgset, size_t *size)
size_t soa_from_size = rrset_binary_size(chgset->soa_from);
size_t soa_to_size = rrset_binary_size(chgset->soa_to);
changeset_iter_t itt;
changeset_iter_all(&itt, chgset, false);
changeset_iter_all(&itt, chgset);
size_t change_size = 0;
knot_rrset_t rrset = changeset_iter_next(&itt);
......
......@@ -147,7 +147,7 @@ static bool can_remove(const zone_node_t *node, const knot_rrset_t *rr)
static int apply_remove(apply_ctx_t *ctx, changeset_t *chset)
{
changeset_iter_t itt;
changeset_iter_rem(&itt, chset, false);
changeset_iter_rem(&itt, chset);
knot_rrset_t rr = changeset_iter_next(&itt);
while (!knot_rrset_empty(&rr)) {
......@@ -168,7 +168,7 @@ static int apply_remove(apply_ctx_t *ctx, changeset_t *chset)
static int apply_add(apply_ctx_t *ctx, changeset_t *chset)
{
changeset_iter_t itt;
changeset_iter_add(&itt, chset, false);
changeset_iter_add(&itt, chset);
knot_rrset_t rr = changeset_iter_next(&itt);
while(!knot_rrset_empty(&rr)) {
......
......@@ -65,8 +65,8 @@ static void cleanup_iter_list(list_t *l)
}
/*! \brief Inits changeset iterator with given HAT-tries. */
static int changeset_iter_init(changeset_iter_t *ch_it,
const changeset_t *ch, bool sorted, size_t tries, ...)
static int changeset_iter_init(changeset_iter_t *ch_it, const changeset_t *ch,
size_t tries, ...)
{
memset(ch_it, 0, sizeof(*ch_it));
init_list(&ch_it->iters);
......@@ -77,10 +77,7 @@ static int changeset_iter_init(changeset_iter_t *ch_it,
for (size_t i = 0; i < tries; ++i) {
hattrie_t *t = va_arg(args, hattrie_t *);
if (t) {
if (sorted) {
hattrie_build_index(t);
}
hattrie_iter_t *it = hattrie_iter_begin(t, sorted);
hattrie_iter_t *it = hattrie_iter_begin(t);
if (it == NULL) {
cleanup_iter_list(&ch_it->iters);
return KNOT_ENOMEM;
......@@ -221,7 +218,7 @@ bool changeset_empty(const changeset_t *ch)
}
changeset_iter_t itt;
changeset_iter_all(&itt, ch, false);
changeset_iter_all(&itt, ch);
knot_rrset_t rr = changeset_iter_next(&itt);
changeset_iter_clear(&itt);
......@@ -236,7 +233,7 @@ size_t changeset_size(const changeset_t *ch)
}
changeset_iter_t itt;
changeset_iter_all(&itt, ch, false);
changeset_iter_all(&itt, ch);
size_t size = 0;
knot_rrset_t rr = changeset_iter_next(&itt);
......@@ -353,7 +350,7 @@ int changeset_remove_removal(changeset_t *ch, const knot_rrset_t *rrset)
int changeset_merge(changeset_t *ch1, const changeset_t *ch2)
{
changeset_iter_t itt;
changeset_iter_add(&itt, ch2, false);
changeset_iter_add(&itt, ch2);
knot_rrset_t rrset = changeset_iter_next(&itt);
while (!knot_rrset_empty(&rrset)) {
......@@ -366,7 +363,7 @@ int changeset_merge(changeset_t *ch1, const changeset_t *ch2)
}
changeset_iter_clear(&itt);
changeset_iter_rem(&itt, ch2, false);
changeset_iter_rem(&itt, ch2);
rrset = changeset_iter_next(&itt);
while (!knot_rrset_empty(&rrset)) {
......@@ -438,22 +435,19 @@ void changeset_free(changeset_t *ch)
free(ch);
}
int changeset_iter_add(changeset_iter_t *itt, const changeset_t *ch, bool sorted)
int changeset_iter_add(changeset_iter_t *itt, const changeset_t *ch)
{
return changeset_iter_init(itt, ch, sorted, 2,
ch->add->nodes, ch->add->nsec3_nodes);
return changeset_iter_init(itt, ch, 2, ch->add->nodes, ch->add->nsec3_nodes);
}
int changeset_iter_rem(changeset_iter_t *itt, const changeset_t *ch, bool sorted)
int changeset_iter_rem(changeset_iter_t *itt, const changeset_t *ch)
{
return changeset_iter_init(itt, ch, sorted, 2,
ch->remove->nodes, ch->remove->nsec3_nodes);
return changeset_iter_init(itt, ch, 2, ch->remove->nodes, ch->remove->nsec3_nodes);
}
int changeset_iter_all(changeset_iter_t *itt, const changeset_t *ch, bool sorted)
int changeset_iter_all(changeset_iter_t *itt, const changeset_t *ch)
{
return changeset_iter_init(itt, ch, sorted, 4,
ch->add->nodes, ch->add->nsec3_nodes,
return changeset_iter_init(itt, ch, 4, ch->add->nodes, ch->add->nsec3_nodes,
ch->remove->nodes, ch->remove->nsec3_nodes);
}
......
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -174,35 +174,32 @@ void changeset_free(changeset_t *ch);
/*!
* \brief Inits changeset iteration structure with changeset additions.
*
* \param itt Iterator to init.
* \param ch Changeset to use.
* \param sorted Sort the iteration?
* \param itt Iterator to init.
* \param ch Changeset to use.
*
* \return KNOT_E*
*/
int changeset_iter_add(changeset_iter_t *itt, const changeset_t *ch, bool sorted);
int changeset_iter_add(changeset_iter_t *itt, const changeset_t *ch);
/*!
* \brief Inits changeset iteration structure with changeset removals.
*
* \param itt Iterator to init.
* \param ch Changeset to use.
* \param sorted Sort the iteration?
* \param itt Iterator to init.
* \param ch Changeset to use.
*
* \return KNOT_E*
*/
int changeset_iter_rem(changeset_iter_t *itt, const changeset_t *ch, bool sorted);
int changeset_iter_rem(changeset_iter_t *itt, const changeset_t *ch);
/*!
* \brief Inits changeset iteration structure with changeset additions and removals.
*
* \param itt Iterator to init.
* \param ch Changeset to use.
* \param sorted Sort the iteration?
* \param itt Iterator to init.
* \param ch Changeset to use.
*
* \return KNOT_E*
*/
int changeset_iter_all(changeset_iter_t *itt, const changeset_t *ch, bool sorted);