return p->bucket_list[id];
}
+/*
+ * Allocate unique ID for bucket
+ */
+static inline u32
+get_new_bucket_id(struct aggregator_proto *p)
+{
+ u32 id = hmap_first_zero(&p->bucket_id_map);
+ hmap_set(&p->bucket_id_map, id);
+ return id;
+}
+
static inline int
popcount32(u32 x)
{
return node;
}
-/*
- * Assign unique ID to @bucket
- */
-static void
-assign_bucket_id(struct aggregator_proto *p, struct aggregator_bucket *bucket)
-{
- assert(p != NULL);
- assert(bucket != NULL);
- assert(bucket->id == 0);
-
- bucket->id = hmap_first_zero(&p->bucket_id_map);
- hmap_set(&p->bucket_id_map, bucket->id);
-}
-
static void
before_check(const struct trie_node *node)
{
memcpy(new_bucket, tmp_bucket, sizeof(*new_bucket) + sizeof(new_bucket->aggr_data[0]) * p->aggr_on_count);
HASH_INSERT2(p->buckets, AGGR_BUCK, p->p.pool, new_bucket);
- assign_bucket_id(p, new_bucket);
+ new_bucket->id = get_new_bucket_id(p);
proto_insert_bucket(p, new_bucket);
}
new_bucket->hash = mem_hash_value(&haux);
/* Assign ID to root node */
- assign_bucket_id(p, new_bucket);
+ new_bucket->id = get_new_bucket_id(p);
proto_insert_bucket(p, new_bucket);
assert(get_bucket_ptr(p, new_bucket->id) == new_bucket);