From de88e9ff168cbb71d4ab4c48df949b2e25d1b23d Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 21 Dec 2025 20:22:35 +0500 Subject: [PATCH] added List_T_destroyWithElements --- include/tlibc/collections/List.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/tlibc/collections/List.h b/include/tlibc/collections/List.h index 4726f17..d5677db 100755 --- a/include/tlibc/collections/List.h +++ b/include/tlibc/collections/List.h @@ -39,6 +39,13 @@ static inline List(T) List_##T##_copy(const List(T)* src) { \ \ static inline void List_##T##_destroy(List(T)* self) { _List_destroy((void*)self); } \ \ +static inline void List_##T##_destroyWithElements(List(T)* self, void (*elem_destructor)(T*)) { \ + for(u32 i = 0; i < self->len; i++){ \ + elem_destructor(self->data + i);\ + } \ + _List_destroy((void*)self); \ +} \ + \ /* alloc bigger buffer if size + len_to_add won't fit in current */ \ static inline void List_##T##_increaseCapacity(List(T)* self, u32 len_to_add){ \ _List_increaseCapacity((void*)self, len_to_add); \