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); \