X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Flist.c;h=9b67791120c3746decab18d0d620aaacc954fd05;hb=268c8545aaf83b7433f43402f5c77e39e20006ef;hp=a26c58d603555a7bfceb77fa3a18774773a8758e;hpb=ce8775000ab38229a78ecf3dc26bab008ca0f332;p=tinc diff --git a/src/list.c b/src/list.c index a26c58d6..9b677911 100644 --- a/src/list.c +++ b/src/list.c @@ -91,6 +91,46 @@ list_node_t *list_insert_tail(list_t *list, void *data) { return node; } +list_node_t *list_insert_after(list_t *list, list_node_t *after, void *data) { + list_node_t *node; + + node = list_alloc_node(); + + node->data = data; + node->next = after->next; + node->prev = after; + after->next = node; + + if(node->next) + node->next->prev = node; + else + list->tail = node; + + list->count++; + + return node; +} + +list_node_t *list_insert_before(list_t *list, list_node_t *before, void *data) { + list_node_t *node; + + node = list_alloc_node(); + + node->data = data; + node->next = before; + node->prev = before->prev; + before->prev = node; + + if(node->prev) + node->prev->next = node; + else + list->head = node; + + list->count++; + + return node; +} + void list_unlink_node(list_t *list, list_node_t *node) { if(node->prev) node->prev->next = node->next;