}
/*
- * ma_get_node_alloc_cnt() - Get the number of allocations stored in this node.
+ * ma_node_alloc_cnt() - Get the number of allocations stored in this node.
* @node: The maple node
*
* Used to calculate the total allocated nodes in a maple state. See
* Returns: The count of the allocated nodes stored in this nodes slots.
*
*/
-static inline int ma_get_node_alloc_cnt(const struct maple_node *node)
+static inline int ma_node_alloc_cnt(const struct maple_node *node)
{
- int ret = 1;
int slot = 0;
while (slot < MAPLE_NODE_SLOTS) {
if (!node->slot[slot])
- return ret;
-
- if (ma_mnode_ptr(node->slot[slot])->slot[0]) {
- ret += ma_get_node_alloc_cnt(
- ma_mnode_ptr(node->slot[slot]));
- } else {
- ret++;
- }
+ break;
slot++;
}
- return ret;
+ return slot;
}
/*
static inline int mas_alloc_cnt(const struct ma_state *mas)
{
struct maple_node *node = mas_get_alloc(mas);
+ int ret = 1;
+ int slot = 0;
if (!node)
return 0;
- return ma_get_node_alloc_cnt(node);
+ slot = ma_node_alloc_cnt(node);
+ ret += slot;
+ while (--slot >= 0) {
+ if (ma_mnode_ptr(node->slot[slot])->slot[0])
+ ret += ma_node_alloc_cnt(node->slot[slot]);
+ }
+ return ret;
}
/*