diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-11-04 20:19:01 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-11-04 20:19:01 +0100 |
commit | 1e78dcbe51419124846e1f35e540cb0253362231 (patch) | |
tree | 8569be830565c3093184bcfbfa07605f918846f3 /udev/lib/libudev-list.c | |
parent | a0e17034eecf3933223503377b5e3f4c4eac0e86 (diff) |
fix list handling in enumerate and rules file sorting
Diffstat (limited to 'udev/lib/libudev-list.c')
-rw-r--r-- | udev/lib/libudev-list.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/udev/lib/libudev-list.c b/udev/lib/libudev-list.c index e681e23e84..9d157616a8 100644 --- a/udev/lib/libudev-list.c +++ b/udev/lib/libudev-list.c @@ -28,8 +28,8 @@ #include "libudev-private.h" struct udev_list_entry { - struct udev *udev; struct udev_list_node node; + struct udev *udev; struct udev_list_node *list; char *name; char *value; @@ -86,15 +86,22 @@ static struct udev_list_entry *list_node_to_entry(struct udev_list_node *node) } /* insert entry into a list as the last element */ -static void list_entry_append(struct udev_list_entry *new, struct udev_list_node *list) +void udev_list_entry_append(struct udev_list_entry *new, struct udev_list_node *list) { /* inserting before the list head make the node the last node in the list */ udev_list_node_insert_between(&new->node, list->prev, list); new->list = list; } +/* remove entry from a list */ +void udev_list_entry_remove(struct udev_list_entry *entry) +{ + udev_list_node_remove(&entry->node); + entry->list = NULL; +} + /* insert entry into a list, before a given existing entry */ -static void list_entry_insert_before(struct udev_list_entry *new, struct udev_list_entry *entry) +void udev_list_entry_insert_before(struct udev_list_entry *new, struct udev_list_entry *entry) { udev_list_node_insert_between(&new->node, entry->node.prev, &entry->node); new->list = entry->list; @@ -150,14 +157,14 @@ struct udev_list_entry *udev_list_entry_add(struct udev *udev, struct udev_list_ } } if (entry_loop != NULL) - list_entry_insert_before(entry_new, entry_loop); + udev_list_entry_insert_before(entry_new, entry_loop); else - list_entry_append(entry_new, list); + udev_list_entry_append(entry_new, list); dbg(udev, "'%s=%s' added\n", entry_new->name, entry_new->value); return entry_new; } -void udev_list_entry_remove(struct udev_list_entry *entry) +void udev_list_entry_delete(struct udev_list_entry *entry) { udev_list_node_remove(&entry->node); free(entry->name); @@ -171,20 +178,7 @@ void udev_list_cleanup_entries(struct udev *udev, struct udev_list_node *list) struct udev_list_entry *entry_tmp; udev_list_entry_foreach_safe(entry_loop, entry_tmp, udev_list_get_entry(list)) - udev_list_entry_remove(entry_loop); -} - -void udev_list_entry_move_to_end(struct udev_list_entry *list_entry) -{ - udev_list_node_remove(&list_entry->node); - udev_list_node_insert_between(&list_entry->node, list_entry->list->prev, list_entry->list); -} - -void udev_list_entry_move_before(struct udev_list_entry *list_entry, struct udev_list_entry *entry) -{ - udev_list_node_remove(&list_entry->node); - udev_list_node_insert_between(&list_entry->node, entry->node.prev, &entry->node); - list_entry->list = entry->list; + udev_list_entry_delete(entry_loop); } struct udev_list_entry *udev_list_get_entry(struct udev_list_node *list) |