From 5a3b1437623c4f0ceacf08d2c7a808fc2f0243a2 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 14 Jul 2024 16:02:19 +0100 Subject: [PATCH] Add list_remove function --- include/list/typed_list.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/list/typed_list.h b/include/list/typed_list.h index 24ea203..eeabe52 100644 --- a/include/list/typed_list.h +++ b/include/list/typed_list.h @@ -44,6 +44,10 @@ LP->items[(LP->count)++] = ITEM; \ } while (0) +#define list_remove(LP, IDX) \ + do { \ + LP->items[IDX] = LP->items[(LP->count)--]; \ + } while (0) #define list_pop(LP) (LP->count -= 1) #define list_get(LP, IDX) LP->items[IDX]