From 5b4d00d6cff955a31a2179d613dcaa3ade327d28 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 2 Aug 2020 21:39:48 +0200 Subject: list: Add list_pop_back --- common/list.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/list.c b/common/list.c index 1a86837..d38daa0 100644 --- a/common/list.c +++ b/common/list.c @@ -74,3 +74,12 @@ void *list_pop_front(struct list *list) { list_del(list, 0); return item; } + +void *list_pop_back(struct list *list) { + if (list->length == 0) { + return NULL; + } + void *item = list->items[list->length - 1]; + list->length -= 1; + return item; +} -- cgit v1.2.3