implemented List_increaseCapacity_size
This commit is contained in:
@@ -21,6 +21,8 @@ List_ List_alloc_size(u32 initial_size);
|
||||
|
||||
List_ List_copy(List_ src);
|
||||
|
||||
// alloc bigger buffer if size + size_to_add won't fit in current
|
||||
void List_increaseCapacity_size(List_* self, u32 size_to_add);
|
||||
void* List_expand_size(List_* self, u32 size_to_add);
|
||||
#define List_push(SELF, T, VALUE) *(T*)(List_expand_size(SELF, sizeof(T))) = VALUE
|
||||
#define List_pushMany(SELF, T, VALUES_PTR, COUNT) List_push_size(SELF, VALUES_PTR, (COUNT) * sizeof(T))
|
||||
@@ -30,4 +32,6 @@ void List_push_size(List_* self, void* values, u32 size);
|
||||
bool List_removeAt_size(List_* self, u32 i, u32 remove_size);
|
||||
|
||||
#define List_len(SELF, T) (SELF.size / sizeof(T))
|
||||
#define List_index(SELF, T, I) ((T*)SELF.data)[I]
|
||||
|
||||
#define List_castTo_Array(SELF) Array_construct_size(SELF.data, SELF.size)
|
||||
|
||||
@@ -16,8 +16,10 @@ void StringBuilder_destroy(StringBuilder* b);
|
||||
static inline StringBuilder StringBuilder_copy(const StringBuilder* b){
|
||||
return (StringBuilder) { .buffer = List_copy(b->buffer) };
|
||||
}
|
||||
static inline void StringBuilder_expand(StringBuilder* b, u32 size_to_add){
|
||||
List_expand_size(&b->buffer, size_to_add);
|
||||
|
||||
// alloc bigger buffer if size + size_to_add won't fit in current
|
||||
static inline void StringBuilder_increaseCapacity(StringBuilder* b, u32 size_to_add){
|
||||
List_increaseCapacity_size(&b->buffer, size_to_add);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user