From 71ced998122c357bc62e54d9bb4e124c88acf94b Mon Sep 17 00:00:00 2001 From: nasr Date: Sun, 8 Mar 2026 21:01:43 +0000 Subject: refactor(main): worked on string handling in C and other stuff --- source/base/base_string.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source/base/base_string.h') diff --git a/source/base/base_string.h b/source/base/base_string.h index 189b38a..4e0d923 100644 --- a/source/base/base_string.h +++ b/source/base/base_string.h @@ -1,13 +1,18 @@ #ifndef BASE_STRING_H #define BASE_STRING_H -#include - #define StringLit(string) \ (string8){ .data = (u8 *)(string), .size = (sizeof(string) - 1) } - #define PushString(arena, size) \ - (string8){ (u8 *)PushArray((arena), u8, (size)), (u64)(size) } +#define PushString(arena, size) \ + ({ \ + string8 *result = PushStruct((arena), string8); \ + result->data = PushArray((arena), u8, (size)); \ + result->size = (u64)(size); \ + result; \ + }) + +#define String8Cast(literal, literal_count) ( string8 ){( u8 * )( literal ),( u64 )( literal_count ) } #define StringFmt "%.*s" #define ULongFmt "%lu" @@ -50,10 +55,8 @@ string8_append_char(string8 *buf, u8 c) read_only global_variable string8 nil_string = { - .data = NULL, .size = 0, - }; #endif /* BASE_STRING_H */ -- cgit v1.3