Remove Allocator stuff

This commit is contained in:
Krzosa Karol
2022-10-10 10:22:04 +02:00
parent 2f153a7cd3
commit 7aa0ba56b6
14 changed files with 69 additions and 192 deletions

View File

@@ -159,8 +159,8 @@ utf16_to_utf32(U16 *c, S32 max_advance) {
}
function String32
string16_to_string32(Allocator *allocator, String16 string){
String32 result = {exp_alloc_array(allocator, U32, string.len+1)};
string16_to_string32(Arena *allocator, String16 string){
String32 result = {arena_push_array(allocator, U32, string.len+1)};
for(S64 i = 0; i < string.len;){
UTF32_Result decode = utf16_to_utf32(string.str + i, string.len - i);
if(!decode.error){
@@ -175,8 +175,8 @@ string16_to_string32(Allocator *allocator, String16 string){
}
function String32
string8_to_string32(Allocator *allocator, String string){
String32 result = {exp_alloc_array(allocator, U32, string.len+1)};
string8_to_string32(Arena *allocator, String string){
String32 result = {arena_push_array(allocator, U32, string.len+1)};
for(S64 i = 0; i < string.len;){
UTF32_Result decode = utf8_to_utf32(string.str + i, string.len - i);
if(!decode.error){
@@ -190,8 +190,8 @@ string8_to_string32(Allocator *allocator, String string){
}
function String16
string8_to_string16(Allocator *allocator, String in){
String16 result = {exp_alloc_array(allocator, U16, (in.len*2)+1)}; // @Note(Krzosa): Should be more then enough space
string8_to_string16(Arena *allocator, String in){
String16 result = {arena_push_array(allocator, U16, (in.len*2)+1)}; // @Note(Krzosa): Should be more then enough space
for(S64 i = 0; i < in.len;){
UTF32_Result decode = utf8_to_utf32(in.str + i, in.len - i);
if(!decode.error){
@@ -212,8 +212,8 @@ string8_to_string16(Allocator *allocator, String in){
}
function String
string16_to_string8(Allocator *allocator, String16 in){
String result = {exp_alloc_array(allocator, U8, in.len*4+1)};
string16_to_string8(Arena *allocator, String16 in){
String result = {arena_push_array(allocator, U8, in.len*4+1)};
for(S64 i = 0; i < in.len;){
UTF32_Result decode = utf16_to_utf32(in.str + i, in.len - i);
if(!decode.error){
@@ -266,8 +266,8 @@ string16_from_widechar(wchar_t *string){
}
function String
string16_copy(Allocator *a, String string){
U8 *copy = exp_alloc_array(a, U8, string.len+1);
string16_copy(Arena *a, String string){
U8 *copy = arena_push_array(a, U8, string.len+1);
memory_copy(copy, string.str, string.len);
copy[string.len] = 0;
return String{copy, string.len};