commit efac3865ae725607eac0280be984b614c1ea2f88 parent e7393433f3699126f4453d973129305300333581 Author: Louis Burda <quent.burda@gmail.com> Date: Sat, 12 Feb 2022 15:10:49 +0100 Allow negative tail offsets for list_at Diffstat:
M | src/list.c | | | 5 | ++++- |
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/list.c b/src/list.c @@ -96,7 +96,10 @@ list_at(struct list *list, int n) { ASSERT(list != NULL); - return link_iter(list->head.next, n); + if (n >= 0) + return link_iter_fwd(list->head.next, n); + else + return link_iter_bwd(&list->tail, -n); } struct link *