summaryrefslogtreecommitdiff
path: root/lib/lists.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2019-08-19 14:36:51 +0200
committerMaria Matejka <mq@ucw.cz>2020-05-01 15:19:12 +0200
commit9ac13d7af25d6b26866bf4f4a4fab371925fb1df (patch)
tree26cf5e3b98910f2d32bb92bb9903a141e7344a8c /lib/lists.c
parente26a5195dd6c62e6f4b80d13b6ecd5f40ee68546 (diff)
Lists: Replaced replace_node() by update_node() which is the only use of that function.
Diffstat (limited to 'lib/lists.c')
-rw-r--r--lib/lists.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/lib/lists.c b/lib/lists.c
index 8553ee27..200576cf 100644
--- a/lib/lists.c
+++ b/lib/lists.c
@@ -153,32 +153,20 @@ 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
+ * update_node - update node after calling realloc on it
+ * @n: node to be updated
*
- * 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.
+ * Fixes neighbor pointers.
*/
LIST_INLINE void
-replace_node(node *old, node *new)
+update_node(node *n)
{
- EXPENSIVE_CHECK(check_list(NULL, old));
+ ASSUME(n->next->prev == n->prev->next);
- if (old != new)
- {
- ASSUME(new->prev == NULL);
- ASSUME(new->next == NULL);
- }
+ n->next->prev = n;
+ n->prev->next = n;
- old->next->prev = new;
- old->prev->next = new;
-
- new->prev = old->prev;
- new->next = old->next;
+ EXPENSIVE_CHECK(check_list(NULL, n));
}
/**