added List<T>_expand

This commit is contained in:
Timerix 2025-11-26 20:56:09 +05:00
parent 8a40caaf10
commit 6a7f0a8715

View File

@ -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); } \ 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) { \ 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; \ *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); \ _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) ATTRIBUTE_WARN_UNUSED_RESULT; \
static inline bool List_##T##_tryRemoveAt(List(T)* self, u32 i, u32 remove_len) { \ static inline bool List_##T##_tryRemoveAt(List(T)* self, u32 i, u32 remove_len) { \
return _List_tryRemoveAt((void*)self, i, remove_len); \ return _List_tryRemoveAt((void*)self, i, remove_len); \