From 521e9a2fc8e0ef1dffe4e590d0d4f65292f0d1df Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Mon, 21 Apr 2025 21:26:23 -0500 Subject: Implement a Concurrent Queue --- src/ll.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ll.c') diff --git a/src/ll.c b/src/ll.c index 9bb1441..285203d 100644 --- a/src/ll.c +++ b/src/ll.c @@ -196,4 +196,16 @@ int dlinkedlist_foreach(dlinkedlist *ll, int (*callback)(void*)) { callback(p->data); return 0; +} + +void * dlinkedlist_poplast(dlinkedlist *ll) { + if(!ll) + RETURNWERR(EINVAL, NULL); + if(dlinkedlist_isempty(ll)) + RETURNWERR(ENODATA, NULL); + + void *data = dlinkedlist_get(ll, ll->size - 1); + dlinkedlist_remove(ll, ll->size - 1); + + return data; } \ No newline at end of file -- cgit v1.2.3