Removing heap allocations, Porting to Unix

This commit is contained in:
Krzosa Karol
2022-10-09 10:34:23 +02:00
parent aa2b4d90e4
commit b22e1ac0db
13 changed files with 260 additions and 269 deletions

View File

@@ -141,7 +141,7 @@ struct String_Builder{
assert(!last && !first);
}
void push_block(SizeU size){
void push_block(size_t size){
String_Builder_Block *block = 0;
if(first_free){
block = first_free;
@@ -218,7 +218,7 @@ function String
string_flatten(Allocator *a, String_Builder *b, String_Builder_Flag flags = String_Builder_Flag_None){
// @Note(Krzosa): Compute size to allocate
S64 size = 1;
if(is_flag_set(flags, String_Builder_Flag_AddSize)) size += sizeof(SizeU);
if(is_flag_set(flags, String_Builder_Flag_AddSize)) size += sizeof(size_t);
For_Linked_List(b->first){
size += it->len;
}
@@ -308,8 +308,8 @@ string_get_prefix(String string, S64 len) {
function String
string_slice(String string, S64 first_index, S64 one_past_last_index) {
assert_msg(first_index < one_past_last_index, "string_slice, first_index is bigger then one_past_last_index");
assert_msg(string.len > 0, "Slicing string of length 0! Might be an error!");
assert_message(first_index < one_past_last_index, "string_slice, first_index is bigger then one_past_last_index");
assert_message(string.len > 0, "Slicing string of length 0! Might be an error!");
String result = string;
if (string.len > 0) {
if (one_past_last_index > first_index) {