]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Use memset in mas_reuse_node on arrays
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 7 Dec 2020 21:02:08 +0000 (16:02 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:36 +0000 (12:33 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 073815614dc3ba37d51b0f8998497320dba5b052..74645b54f571aa4d077abb6e01a2a098b1e328ca 100644 (file)
@@ -2824,26 +2824,25 @@ static inline bool mas_reuse_node(struct ma_state *mas,
                                  struct maple_big_node *bn,
                                  unsigned char end)
 {
-       int i;
-       unsigned long max = mas->max;
+       unsigned long max;
 
        if (mt_in_rcu(mas->tree))
                return false; // Need to be rcu safe.
 
+       max = mas->max;
        mab_mas_cp(bn, 0, bn->b_end, mas);
        mas->max = max;
 
        // Zero end of node.
        if (end > bn->b_end) {
-               for (i = bn->b_end + 1; i < mt_pivots[bn->type]; i++) {
-                       mte_set_slot(mas->node, i, NULL);
-                       mte_set_pivot(mas->node, i, 0);
-
-               //      if (!mte_is_leaf(mas->node) && mt_is_alloc(mas->tree))
-               //              mte_set_gap(mas->node, i, 0);
-               }
-               mte_set_slot(mas->node, mt_slots[bn->type] - 1, NULL);
-
+               enum maple_type mt = mte_node_type(mas->node);
+               struct maple_node *mn = mas_mn(mas);
+               unsigned long *pivots = ma_pivots(mn, mt);
+               void **slots = ma_slots(mn, mt);
+               char zero = mt_slots[mt] - bn->b_end - 1;
+
+               memset(slots + bn->b_end + 1, 0, sizeof(void *) * zero--);
+               memset(pivots + bn->b_end + 1, 0, sizeof(unsigned long *) * zero);
        }
        return true;