new StringBuilder functions

This commit is contained in:
2025-11-10 06:55:26 +05:00
parent 1406189511
commit 57c5942fcc
7 changed files with 82 additions and 45 deletions

View File

@@ -7,12 +7,19 @@ List_ List_alloc_size(u32 initial_size){
return List_construct_size(malloc(allocated_size), 0, allocated_size);
}
void* List_expand_size(List_* ptr, u32 expansion_size){
List_ List_copy(const List_ src){
List_ copy = List_alloc_size(src.allocated_size);
if(copy.data != NULL)
memcpy(copy.data, src.data, src.size);
return copy;
}
void* List_expand_size(List_* ptr, u32 size_to_add){
u32 occupied_size = ptr->size;
u32 expanded_alloc_size = ptr->allocated_size;
if(expanded_alloc_size == 0)
expanded_alloc_size = 64;
ptr->size += expansion_size;
ptr->size += size_to_add;
while(ptr->size > expanded_alloc_size){
expanded_alloc_size *= 2;
}