diff --git a/include/tlibc/collections/List.h b/include/tlibc/collections/List.h index 9824fdf..8a4c3ed 100755 --- a/include/tlibc/collections/List.h +++ b/include/tlibc/collections/List.h @@ -37,8 +37,18 @@ static inline List(T) List_##T##_copy(const List(T)* src) { \ \ static inline void List_##T##_destroy(List(T)* self) { _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); \ +} \ + \ +/* call increaseCapacity and return pointer to next empty cell */ \ +static inline T* List_##T##_expand(List(T)* self, u32 len_to_add){ \ + return (T*)_List_expand((void*)self, len_to_add); \ +} \ + \ static inline void List_##T##_push(List(T)* self, T value) { \ - T* empty_cell = (T*)(_List_expand((void*)self, 1)); \ + T* empty_cell = List_##T##_expand(self, 1); \ *empty_cell = value; \ } \ \ @@ -46,11 +56,6 @@ static inline void List_##T##_pushMany(List(T)* self, T* values_ptr, u32 len) { _List_push((void*)self, values_ptr, len); \ } \ \ -/* 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); \ -} \ - \ static inline bool List_##T##_tryRemoveAt(List(T)* self, u32 i, u32 remove_len) ATTRIBUTE_WARN_UNUSED_RESULT; \ static inline bool List_##T##_tryRemoveAt(List(T)* self, u32 i, u32 remove_len) { \ return _List_tryRemoveAt((void*)self, i, remove_len); \