aboutsummaryrefslogtreecommitdiff
path: root/common/list.c
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-02 21:39:48 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-02 21:46:13 +0200
commit5b4d00d6cff955a31a2179d613dcaa3ade327d28 (patch)
tree99359d933ca07a404fd79a359991d426f0f3e1fd /common/list.c
parentb751481e5c0bed1b81b7c769923e772e9fd84e9d (diff)
list: Add list_pop_back
Diffstat (limited to 'common/list.c')
-rw-r--r--common/list.c9
1 files changed, 9 insertions, 0 deletions
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;
+}