diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2013-09-10 12:09:36 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2013-09-10 12:09:36 +0200 |
commit | bf139664aa2ae9956b520ba4813bb6e03bf1a3e8 (patch) | |
tree | 33381e1e2214b32fcb169def039a891b0db58509 /lib/lists.c | |
parent | bff9ce5130d16af2fd802d42bdb2bff00980c9ae (diff) |
Initial BFD commit, work in progress.
Diffstat (limited to 'lib/lists.c')
-rw-r--r-- | lib/lists.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/lists.c b/lib/lists.c index 6d97ff50..58ffd230 100644 --- a/lib/lists.c +++ b/lib/lists.c @@ -101,6 +101,27 @@ rem_node(node *n) } /** + * replace_node - replace a node in a list with another one + * @old: node to be removed + * @new: node to be inserted + * + * Replaces node @old in the list it's linked in with node @new. Node + * @old may be a copy of the original node, which is not accessed + * through the list. The function could be called with @old == @new, + * which just fixes neighbors' pointers in the case that the node + * was reallocated. + */ +LIST_INLINE void +replace_node(node *old, node *new) +{ + old->next->prev = new; + old->prev->next = new; + + new->prev = old->prev; + new->next = old->next; +} + +/** * init_list - create an empty list * @l: list * |