Introduce the allocator stuff again

This commit is contained in:
Krzosa Karol
2022-12-31 16:51:01 +01:00
parent e20edaa3a2
commit 55515ff420
12 changed files with 71 additions and 44 deletions

View File

@@ -160,7 +160,7 @@ utf16_to_utf32(U16 *c, S32 max_advance) {
CORE_Static String32
string16_to_string32(Arena *allocator, String16 string){
String32 result = {arena_push_array(allocator, U32, string.len+1)};
String32 result = {allocate_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){
@@ -176,7 +176,7 @@ string16_to_string32(Arena *allocator, String16 string){
CORE_Static String32
string8_to_string32(Arena *allocator, String string){
String32 result = {arena_push_array(allocator, U32, string.len+1)};
String32 result = {allocate_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){
@@ -191,7 +191,7 @@ string8_to_string32(Arena *allocator, String string){
CORE_Static String16
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
String16 result = {allocate_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){
@@ -213,7 +213,7 @@ string8_to_string16(Arena *allocator, String in){
CORE_Static String
string16_to_string8(Arena *allocator, String16 in){
String result = {arena_push_array(allocator, U8, in.len*4+1)};
String result = {allocate_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){
@@ -267,7 +267,7 @@ string16_from_widechar(wchar_t *string){
CORE_Static String
string16_copy(Arena *a, String string){
U8 *copy = arena_push_array(a, U8, string.len+1);
U8 *copy = allocate_array(a, U8, string.len+1);
memory_copy(copy, string.str, string.len);
copy[string.len] = 0;
return String{copy, string.len};