Commit 2896d53d authored by Daniel Salzman's avatar Daniel Salzman

zone-tree: remove redundant const variant functions

parent ad2b9c67
......@@ -797,8 +797,9 @@ int zone_contents_find_nsec3_for_name(const zone_contents_t *zone,
const zone_node_t *found = NULL, *prev = NULL;
int exact_match = zone_tree_find_less_or_equal(zone->nsec3_nodes, nsec3_name,
&found, &prev);
int exact_match = zone_tree_get_less_or_equal(zone->nsec3_nodes, nsec3_name,
(zone_node_t **)&found,
(zone_node_t **)&prev);
assert(exact_match >= 0);
knot_dname_free(&nsec3_name, NULL);
......
......@@ -240,7 +240,8 @@ static int knot_zone_diff_node(zone_node_t **node_ptr, void *data)
const knot_dname_t *node_owner = node->owner;
assert(node_owner);
zone_tree_find(param->nodes, node_owner, &node_in_second_tree);
zone_tree_get(param->nodes, (knot_dname_t *)node_owner,
(zone_node_t **)&node_in_second_tree);
if (node_in_second_tree == NULL) {
return knot_zone_diff_remove_node(param->changeset, node);
......
......@@ -51,18 +51,8 @@ int zone_tree_insert(zone_tree_t *tree, zone_node_t *node)
return KNOT_EOK;
}
int zone_tree_find(zone_tree_t *tree, const knot_dname_t *owner,
const zone_node_t **found)
{
if (owner == NULL || found == NULL) {
return KNOT_EINVAL;
}
return zone_tree_get(tree, owner, (zone_node_t **)found);
}
int zone_tree_get(zone_tree_t *tree, const knot_dname_t *owner,
zone_node_t **found)
zone_node_t **found)
{
if (owner == NULL) {
return KNOT_EINVAL;
......@@ -85,24 +75,6 @@ int zone_tree_get(zone_tree_t *tree, const knot_dname_t *owner,
return KNOT_EOK;
}
int zone_tree_find_less_or_equal(zone_tree_t *tree,
const knot_dname_t *owner,
const zone_node_t **found,
const zone_node_t **previous)
{
if (owner == NULL || found == NULL || previous == NULL) {
return KNOT_EINVAL;
}
zone_node_t *f = NULL, *p = NULL;
int ret = zone_tree_get_less_or_equal(tree, owner, &f, &p);
*found = f;
*previous = p;
return ret;
}
int zone_tree_get_less_or_equal(zone_tree_t *tree,
const knot_dname_t *owner,
zone_node_t **found,
......
......@@ -79,25 +79,7 @@ int zone_tree_insert(zone_tree_t *tree, zone_node_t *node);
* \retval KNOT_EINVAL
* \retval KNOT_ENOMEM
*/
int zone_tree_find(zone_tree_t *tree,
const knot_dname_t *owner,
const zone_node_t **found);
/*!
* \brief Finds node with the given owner in the zone tree.
*
* \note This function is identical to zone_tree_find() except that it
* returns non-const node.
*
* \param tree Zone tree to search in.
* \param owner Owner of the node to find.
*
* \retval KNOT_EOK
* \retval KNOT_EINVAL
* \retval KNOT_ENOMEM
*/
int zone_tree_get(zone_tree_t *tree,
const knot_dname_t *owner,
int zone_tree_get(zone_tree_t *tree, const knot_dname_t *owner,
zone_node_t **found);
/*!
......@@ -119,33 +101,6 @@ int zone_tree_get(zone_tree_t *tree,
* \retval KNOT_EINVAL
* \retval KNOT_ENOMEM
*/
int zone_tree_find_less_or_equal(zone_tree_t *tree,
const knot_dname_t *owner,
const zone_node_t **found,
const zone_node_t **previous);
/*!
* \brief Tries to find the given domain name in the zone tree and returns the
* associated node and previous node in canonical order.
*
* \note This function is identical to zone_tree_find_less_or_equal()
* except that it returns non-const nodes.
*
* \param zone Zone to search in.
* \param owner Owner of the node to find.
* \param found Found node.
* \param previous Previous node in canonical order (i.e. the one directly
* preceding \a owner in canonical order, regardless if the name
* is in the zone or not).
*
* \retval > 0 if the domain name was found. In such case \a found holds the
* zone node with \a owner as its owner.
* \a previous is set properly.
* \retval 0 if the domain name was not found. \a found may hold any (or none)
* node. \a previous is set properly.
* \retval KNOT_EINVAL
* \retval KNOT_ENOMEM
*/
int zone_tree_get_less_or_equal(zone_tree_t *tree,
const knot_dname_t *owner,
zone_node_t **found,
......
......@@ -88,9 +88,9 @@ int main(int argc, char *argv[])
/* 3. check data test */
passed = 1;
const zone_node_t *node = NULL;
zone_node_t *node = NULL;
for (unsigned i = 0; i < NCOUNT; ++i) {
int r = zone_tree_find(t, NAME[i], &node);
int r = zone_tree_get(t, NAME[i], &node);
if (r != KNOT_EOK || node != NODE + i) {
passed = 0;
break;
......@@ -103,9 +103,9 @@ int main(int argc, char *argv[])
/* 4. ordered lookup */
node = NULL;
const zone_node_t *prev = NULL;
zone_node_t *prev = NULL;
knot_dname_t *tmp_dn = knot_dname_from_str_alloc("z.ac.");
zone_tree_find_less_or_equal(t, tmp_dn, &node, &prev);
zone_tree_get_less_or_equal(t, tmp_dn, &node, &prev);
knot_dname_free(&tmp_dn, NULL);
ok(prev == NODE + 1, "ztree: ordered lookup");
......
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