}
int mas_entry_count(struct ma_state *mas, unsigned long nr_leaves);
+void mas_empty_alloc(struct ma_state *mas);
void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max);
void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max,
}
// Free the allocations.
-static inline void mas_empty_alloc(struct ma_state *mas)
+void mas_empty_alloc(struct ma_state *mas)
{
struct maple_node *node;
return mas->alloc;
}
-int mas_entry_count(struct ma_state *mas, unsigned long nr_entries) {
+int mas_entry_count(struct ma_state *mas, unsigned long nr_entries)
+{
int nonleaf_cap = MAPLE_ARANGE64_SLOTS - 1;
+ struct maple_enode *enode = mas->node;
int nr_nodes;
+ int ret;
if (!mt_is_alloc(mas->tree))
nonleaf_cap = MAPLE_RANGE64_SLOTS - 1;
nr_nodes = DIV_ROUND_UP(nr_entries, MAPLE_RANGE64_SLOTS); // leaves
nr_nodes += DIV_ROUND_UP(nr_nodes, nonleaf_cap);
mas_node_cnt(mas, min(nr_nodes, (int)MAPLE_NODE_MAX));
+
if (!mas_is_err(mas))
return 0;
- return xa_err(mas->node);
+
+ ret = xa_err(mas->node);
+ mas->node = enode;
+ return ret;
}
/*