5 avl_strcmp(const void *k1, const void *k2, void *ptr)
11 __vlist_init(struct vlist_tree *tree, avl_tree_comp cmp,
12 vlist_update_cb update, int offset)
14 tree->key_offset = offset;
15 tree->update = update;
18 avl_init(&tree->avl, cmp, 0, tree);
22 vlist_delete(struct vlist_tree *tree, struct vlist_node *node)
25 avl_delete(&tree->avl, &node->avl);
26 tree->update(tree, NULL, node);
30 vlist_add(struct vlist_tree *tree, struct vlist_node *node)
32 struct vlist_node *old_node = NULL;
33 struct avl_node *anode;
34 void *key = (char *) node + tree->key_offset;
37 node->version = tree->version;
39 anode = avl_find(&tree->avl, key);
41 old_node = container_of(anode, struct vlist_node, avl);
42 if (tree->keep_old || tree->no_delete)
45 avl_delete(&tree->avl, anode);
48 avl_insert(&tree->avl, &node->avl);
51 tree->update(tree, node, old_node);
55 vlist_flush(struct vlist_tree *tree)
57 struct vlist_node *node, *tmp;
59 avl_for_each_element_safe(&tree->avl, node, avl, tmp) {
60 if (node->version == tree->version)
63 vlist_delete(tree, node);
68 vlist_flush_all(struct vlist_tree *tree)