extend vlist code to allow keeping the old data structure instead of the new one...
authorFelix Fietkau <nbd@openwrt.org>
Sun, 2 Oct 2011 17:32:44 +0000 (19:32 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 2 Oct 2011 17:32:44 +0000 (19:32 +0200)
utils.c
utils.h

diff --git a/utils.c b/utils.c
index 42d3176c4e9371b4f59bd07dc98ce3a15300fdef..a67a8c9d5d8dbec47e718260baba07d2008c63ad 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -37,11 +37,16 @@ vlist_add(struct vlist_tree *tree, struct vlist_node *node)
 
        anode = avl_find(&tree->avl, key);
        if (anode) {
+               if (tree->keep_old)
+                       goto update_only;
+
                old_node = container_of(anode, struct vlist_node, avl);
                avl_delete(&tree->avl, anode);
        }
 
        avl_insert(&tree->avl, &node->avl);
+
+update_only:
        tree->update(tree, node, old_node);
 }
 
diff --git a/utils.h b/utils.h
index c8101e7323a88bc790f806a2f058d414ed1886f2..ab739300791a8d6bd6ec4de96e5edcfb342ff6d7 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -28,6 +28,7 @@ struct vlist_tree {
 
        vlist_update_cb update;
        int node_offset;
+       bool keep_old;
 
        int version;
 };