/** Return a chunk of a key (in the low bits) for use in 2^N node de-indexing
*
*/
-static uint16_t get_chunk(uint8_t const *key, int num_bits, int start_bit, int end_bit)
+static uint16_t get_chunk(uint8_t const *key, int start_bit, int num_bits)
{
uint16_t chunk;
fr_cond_assert(num_bits > 0);
fr_cond_assert(num_bits <= 8);
- fr_cond_assert(start_bit < end_bit);
/*
* Load the byte
path->type = FR_TRIE_PATH;
path->bits = end_bit - start_bit;
path->parent = parent;
- path->chunk = get_chunk(key, path->bits, start_bit, end_bit);
+ path->chunk = get_chunk(key, start_bit, path->bits);
/*
* Copy the key over, being sure to zero out unused bits
node = fr_trie_node_alloc(ctx, parent, bits);
if (!node) return NULL;
- chunk = get_chunk(key, node->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, node->bits);
node->trie[chunk] = fr_trie_key_alloc(ctx, (fr_trie_t *) node, key, start_bit + node->bits, end_bit, data);
if (!node->trie[chunk]) {
talloc_free(node); /* no children */
uint16_t chunk;
fr_trie_node_t *node = (fr_trie_node_t *) trie;
- chunk = get_chunk(key, node->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, node->bits);
if (!node->trie[chunk]) {
MPRINT2("no match for node chunk %02x at %d\n", chunk, __LINE__);
return NULL;
uint16_t chunk;
fr_trie_path_t *path = (fr_trie_path_t *) trie;
- chunk = get_chunk(key, path->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, path->bits);
if (chunk != path->chunk) return NULL;
return fr_trie_key_match(path->trie, key, start_bit + path->bits, end_bit, exact);
node = split;
}
- chunk = get_chunk(key, node->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, node->bits);
/*
* The current node exactly fits the key bits.
MPRINT2("forcing bits %d\n", bits);
} else { /* the key is equal in length to, or longer than the path */
- chunk = get_chunk(key, path->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, path->bits);
/*
* The chunk matches exactly. Recurse to
node = fr_trie_node_alloc(ctx, parent, bits);
if (!node) return -1; /* @todo - don't leave "path" split in two */
- chunk = get_chunk(key, node->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, node->bits);
node->trie[chunk] = fr_trie_key_alloc(ctx, (fr_trie_t *) node, key, start_bit + node->bits, end_bit, data);
if (!node->trie[chunk]) {
MPRINT("Failed key_alloc at %d\n", __LINE__);
uint32_t chunk;
void *data;
- chunk = get_chunk(key, node->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, node->bits);
if (!node->trie[chunk]) return NULL;
data = fr_trie_key_remove(ctx, (fr_trie_t *) node, &node->trie[chunk], key, start_bit + node->bits, end_bit);
uint32_t chunk;
void *data;
- chunk = get_chunk(key, path->bits, start_bit, end_bit);
+ chunk = get_chunk(key, start_bit, path->bits);
/*
* No match, can't remove it.