return rt->nr_entries;
}
-static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv);
+static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv);
-static bool _insert_unset(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_unset(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
unsigned len = ke - kb;
return true;
}
-static bool _insert_value(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_value(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
unsigned len = ke - kb;
return true;
}
-static bool _insert_value_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_value_chain(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
struct value_chain *vc = v->value.ptr;
return _insert(rt, &vc->child, kb, ke, rv);
return rhs;
}
-static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
struct prefix_chain *pc = v->value.ptr;
return true;
}
-static bool _insert_node4(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_node4(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
struct node4 *n4 = v->value.ptr;
if (n4->nr_entries == 4) {
return true;
}
-static bool _insert_node16(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_node16(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
struct node16 *n16 = v->value.ptr;
return true;
}
-static bool _insert_node48(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_node48(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
struct node48 *n48 = v->value.ptr;
if (n48->nr_entries == 48) {
return true;
}
-static bool _insert_node256(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert_node256(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
struct node256 *n256 = v->value.ptr;
bool r, was_unset = n256->values[*kb].type == UNSET;
}
// FIXME: the tree should not be touched if insert fails (eg, OOM)
-static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
+static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
{
if (kb == ke) {
if (v->type == UNSET) {
struct lookup_result {
struct value *v;
- uint8_t *kb;
+ const uint8_t *kb;
};
-static struct lookup_result _lookup_prefix(struct value *v, uint8_t *kb, uint8_t *ke)
+static struct lookup_result _lookup_prefix(struct value *v, const uint8_t *kb, const uint8_t *ke)
{
unsigned i;
struct value_chain *vc;
return (struct lookup_result) {.v = v, .kb = kb};
}
-bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value rv)
+bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen, union radix_value rv)
{
+ const uint8_t *kb = key;
+ const uint8_t *ke = kb + keylen;
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
return _insert(rt, lr.v, lr.kb, ke, rv);
}
memset(((uint8_t *) array) + (count - 1) * obj_size, 0, obj_size);
}
-static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke)
+static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb, const uint8_t *ke)
{
bool r;
unsigned i, j;
return false;
}
-bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_end)
+bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen)
{
- if (_remove(rt, &rt->root, key_begin, key_end)) {
+ const uint8_t *kb = key;
+ const uint8_t *ke = kb + keylen;
+
+ if (_remove(rt, &rt->root, kb, ke)) {
rt->nr_entries--;
return true;
}
//----------------------------------------------------------------
-static bool _prefix_chain_matches(struct lookup_result *lr, uint8_t *ke)
+static bool _prefix_chain_matches(const struct lookup_result *lr, const uint8_t *ke)
{
// It's possible the top node is a prefix chain, and
// the remaining key matches part of it.
if (lr->v->type == PREFIX_CHAIN) {
unsigned i, rlen = ke - lr->kb;
- struct prefix_chain *pc = lr->v->value.ptr;
+ const struct prefix_chain *pc = lr->v->value.ptr;
if (rlen < pc->len) {
for (i = 0; i < rlen; i++)
if (pc->prefix[i] != lr->kb[i])
return false;
}
-static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke, unsigned *count)
+static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uint8_t *kb, const uint8_t *ke, unsigned *count)
{
bool r;
unsigned i, j, len;
return false;
}
-unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
+unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *prefix, size_t prefix_len)
{
+ const uint8_t *kb = prefix;
+ const uint8_t *ke = kb + prefix_len;
unsigned count = 0;
if (_remove_subtree(rt, &rt->root, kb, ke, &count))
//----------------------------------------------------------------
-bool radix_tree_lookup(struct radix_tree *rt,
- uint8_t *kb, uint8_t *ke, union radix_value *result)
+bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
+ union radix_value *result)
{
+ const uint8_t *kb = key;
+ const uint8_t *ke = kb + keylen;
struct value_chain *vc;
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
if (lr.kb == ke) {
break;
case VALUE:
- return it->visit(it, NULL, NULL, v->value);
+ return it->visit(it, NULL, 0, v->value);
case VALUE_CHAIN:
vc = v->value.ptr;
- return it->visit(it, NULL, NULL, vc->value) && _iterate(&vc->child, it);
+ return it->visit(it, NULL, 0, vc->value) && _iterate(&vc->child, it);
case PREFIX_CHAIN:
pc = v->value.ptr;
return false;
}
-void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
+void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
struct radix_tree_iterator *it)
{
+ const uint8_t *kb = key;
+ const uint8_t *ke = kb + keylen;
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
if (lr.kb == ke || _prefix_chain_matches(&lr, ke))
(void) _iterate(lr.v, it);
union radix_value v;
unsigned char k = 'a';
v.n = 65;
- T_ASSERT(radix_tree_insert(rt, &k, &k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, &k, 1, v));
T_ASSERT(radix_tree_is_well_formed(rt));
v.n = 0;
- T_ASSERT(radix_tree_lookup(rt, &k, &k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, &k, 1, &v));
T_ASSERT_EQUAL(v.n, 65);
}
for (i = 0; i < count; i++) {
k = i;
v.n = 100 + i;
- T_ASSERT(radix_tree_insert(rt, &k, &k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, &k, 1, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < count; i++) {
k = i;
- T_ASSERT(radix_tree_lookup(rt, &k, &k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, &k, 1, &v));
T_ASSERT_EQUAL(v.n, 100 + i);
}
}
for (i = 0; i < count; i++) {
k = i;
v.n = 100 + i;
- T_ASSERT(radix_tree_insert(rt, &k, &k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, &k, 1, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < count; i++) {
k = i;
v.n = 1000 + i;
- T_ASSERT(radix_tree_insert(rt, &k, &k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, &k, 1, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < count; i++) {
k = i;
- T_ASSERT(radix_tree_lookup(rt, &k, &k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, &k, 1, &v));
T_ASSERT_EQUAL(v.n, 1000 + i);
}
}
k[0] = i / 256;
k[1] = i % 256;
v.n = 100 + i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < count; i++) {
k[0] = i / 256;
k[1] = i % 256;
- T_ASSERT(radix_tree_lookup(rt, k, k + sizeof(k), &v));
+ T_ASSERT(radix_tree_lookup(rt, k, sizeof(k), &v));
T_ASSERT_EQUAL(v.n, 100 + i);
}
}
k[0] = 100;
k[1] = 200;
v.n = 1024;
- T_ASSERT(radix_tree_insert(rt, k, k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, k, 1, v));
T_ASSERT(radix_tree_is_well_formed(rt));
v.n = 2345;
- T_ASSERT(radix_tree_insert(rt, k, k + 2, v));
+ T_ASSERT(radix_tree_insert(rt, k, 2, v));
T_ASSERT(radix_tree_is_well_formed(rt));
- T_ASSERT(radix_tree_lookup(rt, k, k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 1, &v));
T_ASSERT_EQUAL(v.n, 1024);
- T_ASSERT(radix_tree_lookup(rt, k, k + 2, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 2, &v));
T_ASSERT_EQUAL(v.n, 2345);
}
k[0] = 100;
k[1] = 200;
v.n = 1024;
- T_ASSERT(radix_tree_insert(rt, k, k + 2, v));
+ T_ASSERT(radix_tree_insert(rt, k, 2, v));
T_ASSERT(radix_tree_is_well_formed(rt));
v.n = 2345;
- T_ASSERT(radix_tree_insert(rt, k, k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, k, 1, v));
T_ASSERT(radix_tree_is_well_formed(rt));
- T_ASSERT(radix_tree_lookup(rt, k, k + 2, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 2, &v));
T_ASSERT_EQUAL(v.n, 1024);
- T_ASSERT(radix_tree_lookup(rt, k, k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 1, &v));
T_ASSERT_EQUAL(v.n, 2345);
}
for (n = 0; n < 100000; n++) {
_gen_key(k, k + sizeof(k));
v.n = 1234;
- T_ASSERT(radix_tree_insert(rt, k, k + 32, v));
+ T_ASSERT(radix_tree_insert(rt, k, 32, v));
// FIXME: remove
//T_ASSERT(radix_tree_is_well_formed(rt));
}
_gen_key(k, k + sizeof(k));
v.n = 1234;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
T_ASSERT(radix_tree_is_well_formed(rt));
- T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k)));
+ T_ASSERT(radix_tree_remove(rt, k, sizeof(k)));
T_ASSERT(radix_tree_is_well_formed(rt));
- T_ASSERT(!radix_tree_lookup(rt, k, k + sizeof(k), &v));
+ T_ASSERT(!radix_tree_lookup(rt, k, sizeof(k), &v));
}
static void test_remove_one_byte_keys(void *fixture)
for (i = 0; i < 256; i++) {
k[0] = i;
v.n = i + 1000;
- T_ASSERT(radix_tree_insert(rt, k, k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, k, 1, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < 256; i++) {
k[0] = i;
- T_ASSERT(radix_tree_remove(rt, k, k + 1));
+ T_ASSERT(radix_tree_remove(rt, k, 1));
T_ASSERT(radix_tree_is_well_formed(rt));
for (j = i + 1; j < 256; j++) {
k[0] = j;
- T_ASSERT(radix_tree_lookup(rt, k, k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 1, &v));
if (v.n != j + 1000)
test_fail("v.n (%u) != j + 1000 (%u)\n",
(unsigned) v.n,
for (i = 0; i < 256; i++) {
k[0] = i;
- T_ASSERT(!radix_tree_lookup(rt, k, k + 1, &v));
+ T_ASSERT(!radix_tree_lookup(rt, k, 1, &v));
}
}
for (i = 0; i < 256; i++) {
k[0] = i;
v.n = i + 1000;
- T_ASSERT(radix_tree_insert(rt, k, k + 1, v));
+ T_ASSERT(radix_tree_insert(rt, k, 1, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 256; i; i--) {
k[0] = i - 1;
- T_ASSERT(radix_tree_remove(rt, k, k + 1));
+ T_ASSERT(radix_tree_remove(rt, k, 1));
T_ASSERT(radix_tree_is_well_formed(rt));
for (j = 0; j < i - 1; j++) {
k[0] = j;
- T_ASSERT(radix_tree_lookup(rt, k, k + 1, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 1, &v));
if (v.n != j + 1000)
test_fail("v.n (%u) != j + 1000 (%u)\n",
(unsigned) v.n,
for (i = 0; i < 256; i++) {
k[0] = i;
- T_ASSERT(!radix_tree_lookup(rt, k, k + 1, &v));
+ T_ASSERT(!radix_tree_lookup(rt, k, 1, &v));
}
}
static void test_remove_prefix_keys(void *fixture)
for (i = 0; i < 32; i++) {
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + i, v));
+ T_ASSERT(radix_tree_insert(rt, k, i, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < 32; i++) {
- T_ASSERT(radix_tree_remove(rt, k, k + i));
+ T_ASSERT(radix_tree_remove(rt, k, i));
T_ASSERT(radix_tree_is_well_formed(rt));
for (j = i + 1; j < 32; j++) {
- T_ASSERT(radix_tree_lookup(rt, k, k + j, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, j, &v));
T_ASSERT_EQUAL(v.n, j);
}
}
for (i = 0; i < 32; i++)
- T_ASSERT(!radix_tree_lookup(rt, k, k + i, &v));
+ T_ASSERT(!radix_tree_lookup(rt, k, i, &v));
}
static void test_remove_prefix_keys_reversed(void *fixture)
for (i = 0; i < 32; i++) {
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + i, v));
+ T_ASSERT(radix_tree_insert(rt, k, i, v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < 32; i++) {
- T_ASSERT(radix_tree_remove(rt, k, k + (31 - i)));
+ T_ASSERT(radix_tree_remove(rt, k, (31 - i)));
T_ASSERT(radix_tree_is_well_formed(rt));
for (j = 0; j < 31 - i; j++) {
- T_ASSERT(radix_tree_lookup(rt, k, k + j, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, j, &v));
T_ASSERT_EQUAL(v.n, j);
}
}
for (i = 0; i < 32; i++)
- T_ASSERT(!radix_tree_lookup(rt, k, k + i, &v));
+ T_ASSERT(!radix_tree_lookup(rt, k, i, &v));
}
static void test_remove_prefix(void *fixture)
if (k[0] == 21)
count++;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
// remove keys in a sub range
k[0] = 21;
- T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 1), count);
+ T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, 1), count);
T_ASSERT(radix_tree_is_well_formed(rt));
}
_gen_key(k, k + sizeof(k));
v.n = 1234;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
T_ASSERT(radix_tree_is_well_formed(rt));
- T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, k + 2), 1);
+ T_ASSERT_EQUAL(radix_tree_remove_prefix(rt, k, 2), 1);
T_ASSERT(radix_tree_is_well_formed(rt));
}
// populate some random 16bit keys
for (i = 0; i < 10000; i++) {
_gen_key(k, k + sizeof(k));
- if (radix_tree_lookup(rt, k, k + sizeof(k), &v))
+ if (radix_tree_lookup(rt, k, sizeof(k), &v))
dup_count++;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT_EQUAL(radix_tree_size(rt), 10000 - dup_count);
};
static bool _visit(struct radix_tree_iterator *it,
- uint8_t *kb, uint8_t *ke, union radix_value v)
+ const void *key, size_t keylen, union radix_value v)
{
struct visitor *vt = container_of(it, struct visitor, it);
vt->count++;
for (i = 0; i < 100000; i++) {
_gen_key(k, k + sizeof(k));
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
vt.count = 0;
vt.it.visit = _visit;
- radix_tree_iterate(rt, NULL, NULL, &vt.it);
+ radix_tree_iterate(rt, NULL, 0, &vt.it);
T_ASSERT_EQUAL(vt.count, radix_tree_size(rt));
}
if (k[0] == 21 && k[1] == 12)
subset_count++;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
vt.it.visit = _visit;
k[0] = 21;
k[1] = 12;
- radix_tree_iterate(rt, k, k + 2, &vt.it);
+ radix_tree_iterate(rt, k, 2, &vt.it);
T_ASSERT_EQUAL(vt.count, subset_count);
}
_gen_key(k, k + sizeof(k));
v.n = 1234;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
T_ASSERT(radix_tree_is_well_formed(rt));
vt.count = 0;
vt.it.visit = _visit;
- radix_tree_iterate(rt, k, k + 3, &vt.it);
+ radix_tree_iterate(rt, k, 3, &vt.it);
T_ASSERT_EQUAL(vt.count, 1);
}
for (i = 0; i < 16; i++) {
k[3] = i;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
for (i = 0; i < 16; i++) {
vt.count = 0;
k[3] = i;
- radix_tree_iterate(rt, k, k + 4, &vt.it);
+ radix_tree_iterate(rt, k, 4, &vt.it);
T_ASSERT_EQUAL(vt.count, 1);
}
}
v.n = i;
uint8_t *k = keys + (i * 3);
_gen_key(k, k + 3);
- if (!radix_tree_lookup(rt, k, k + 3, &v)) {
- T_ASSERT(radix_tree_insert(rt, k, k + 3, v));
+ if (!radix_tree_lookup(rt, k, 3, &v)) {
+ T_ASSERT(radix_tree_insert(rt, k, 3, v));
found = true;
}
// double check
for (i = 0; i < DTR_COUNT; i++) {
uint8_t *k = keys + (i * 3);
- T_ASSERT(radix_tree_lookup(rt, k, k + 3, &v));
+ T_ASSERT(radix_tree_lookup(rt, k, 3, &v));
}
for (i = 0; i < DTR_COUNT; i++) {
uint8_t *k = keys + (i * 3);
// FIXME: check the values get passed to the dtr
- T_ASSERT(radix_tree_remove(rt, k, k + 3));
+ T_ASSERT(radix_tree_remove(rt, k, 3));
}
T_ASSERT(c.c == DTR_COUNT);
v.n = i;
uint8_t *k = keys + (i * 3);
_gen_key(k, k + 3);
- if (!radix_tree_lookup(rt, k, k + 3, &v)) {
- T_ASSERT(radix_tree_insert(rt, k, k + 3, v));
+ if (!radix_tree_lookup(rt, k, 3, &v)) {
+ T_ASSERT(radix_tree_insert(rt, k, 3, v));
found = true;
}
// trigger the bug.
k[4] = i;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
k[4] = 0;
- T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k)));
+ T_ASSERT(radix_tree_remove(rt, k, sizeof(k)));
T_ASSERT(radix_tree_is_well_formed(rt));
k[4] = i;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
T_ASSERT(radix_tree_is_well_formed(rt));
}
for (i = 0x6; i < 0x69; i++) {
k[0] = i;
v.n = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
}
memset(k, 0, sizeof(k));
for (i = 0x6; i < 0x69; i++) {
k[0] = i;
- radix_tree_remove_prefix(rt, k, k + 4);
+ radix_tree_remove_prefix(rt, k, 4);
}
T_ASSERT(radix_tree_is_well_formed(rt));
}
for (i = 0; i < 50; i++) {
k[0] = 0x6;
v.n = 0x6;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
- radix_tree_remove_prefix(rt, k, k + 4);
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
+ radix_tree_remove_prefix(rt, k, 4);
}
T_ASSERT(radix_tree_is_well_formed(rt));
k[0] = i;
k[4] = 0xf;
k[5] = 0x1;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
k[4] = 0;
k[5] = 0;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
k[0] = i - 0x32;
k[4] = 0xf;
k[5] = 1;
- T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k)));
+ T_ASSERT(radix_tree_remove(rt, k, sizeof(k)));
k[0] = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
k[0] = i - 0x32;
k[4] = 0;
k[5] = 0;
- T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k)));
+ T_ASSERT(radix_tree_remove(rt, k, sizeof(k)));
k[0] = i;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
}
T_ASSERT(radix_tree_is_well_formed(rt));
memset(k, 0, sizeof(k));
k[0] = 0x6;
- radix_tree_remove_prefix(rt, k, k + 4);
+ radix_tree_remove_prefix(rt, k, 4);
T_ASSERT(radix_tree_is_well_formed(rt));
k[0] = 0x38;
k[4] = 0xf;
k[5] = 0x1;
- T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k)));
+ T_ASSERT(radix_tree_remove(rt, k, sizeof(k)));
T_ASSERT(radix_tree_is_well_formed(rt));
memset(k, 0, sizeof(k));
k[0] = 0x6;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
T_ASSERT(radix_tree_is_well_formed(rt));
k[0] = 0x7;
- radix_tree_remove_prefix(rt, k, k + 4);
+ radix_tree_remove_prefix(rt, k, 4);
T_ASSERT(radix_tree_is_well_formed(rt));
k[0] = 0x38;
- T_ASSERT(radix_tree_remove(rt, k, k + sizeof(k)));
+ T_ASSERT(radix_tree_remove(rt, k, sizeof(k)));
T_ASSERT(radix_tree_is_well_formed(rt));
k[0] = 7;
- T_ASSERT(radix_tree_insert(rt, k, k + sizeof(k), v));
+ T_ASSERT(radix_tree_insert(rt, k, sizeof(k), v));
T_ASSERT(radix_tree_is_well_formed(rt));
}
k.parts.fd = fd;
k.parts.b = b;
- T_ASSERT(radix_tree_lookup(rt, k.bytes, k.bytes + sizeof(k.bytes), &v));
+ T_ASSERT(radix_tree_lookup(rt, k.bytes, sizeof(k.bytes), &v));
T_ASSERT(v.n == expected);
}
k.parts.fd = fd;
k.parts.b = b;
- T_ASSERT(!radix_tree_lookup(rt, k.bytes, k.bytes + sizeof(k.bytes), &v));
+ T_ASSERT(!radix_tree_lookup(rt, k.bytes, sizeof(k.bytes), &v));
}
static void __insert(struct radix_tree *rt, int fd, uint64_t b, uint64_t n)
k.parts.fd = fd;
k.parts.b = b;
v.n = n;
- T_ASSERT(radix_tree_insert(rt, k.bytes, k.bytes + sizeof(k.bytes), v));
+ T_ASSERT(radix_tree_insert(rt, k.bytes, sizeof(k.bytes), v));
}
static void __invalidate(struct radix_tree *rt, int fd)
union key k;
k.parts.fd = fd;
- radix_tree_remove_prefix(rt, k.bytes, k.bytes + sizeof(k.parts.fd));
+ radix_tree_remove_prefix(rt, k.bytes, sizeof(k.parts.fd));
T_ASSERT(radix_tree_is_well_formed(rt));
}