From: Felix Fietkau Date: Sun, 2 Oct 2011 19:36:21 +0000 (+0200) Subject: add a new vlist flag for avoiding automatic delete of entries X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3c024e7b3170bd2d3869a404b08bc20345bc6f81;p=oweals%2Fnetifd.git add a new vlist flag for avoiding automatic delete of entries --- diff --git a/utils.c b/utils.c index cc22290..31a5967 100644 --- a/utils.c +++ b/utils.c @@ -21,7 +21,8 @@ __vlist_init(struct vlist_tree *tree, avl_tree_comp cmp, void vlist_delete(struct vlist_tree *tree, struct vlist_node *node) { - avl_delete(&tree->avl, &node->avl); + if (!tree->no_delete) + avl_delete(&tree->avl, &node->avl); tree->update(tree, NULL, node); } @@ -37,7 +38,7 @@ vlist_add(struct vlist_tree *tree, struct vlist_node *node) anode = avl_find(&tree->avl, key); if (anode) { - if (tree->keep_old) + if (tree->keep_old || !tree->no_delete) goto update_only; old_node = container_of(anode, struct vlist_node, avl); diff --git a/utils.h b/utils.h index d71a8f7..8ef968a 100644 --- a/utils.h +++ b/utils.h @@ -29,6 +29,7 @@ struct vlist_tree { vlist_update_cb update; int key_offset; bool keep_old; + bool no_delete; int version; };