summaryrefslogtreecommitdiff
path: root/source/base/base_string.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/base/base_string.h')
-rw-r--r--source/base/base_string.h15
1 files changed, 9 insertions, 6 deletions
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 @@
1#ifndef BASE_STRING_H 1#ifndef BASE_STRING_H
2#define BASE_STRING_H 2#define BASE_STRING_H
3 3
4#include <string.h>
5
6#define StringLit(string) \ 4#define StringLit(string) \
7 (string8){ .data = (u8 *)(string), .size = (sizeof(string) - 1) } 5 (string8){ .data = (u8 *)(string), .size = (sizeof(string) - 1) }
8 6
9 #define PushString(arena, size) \ 7#define PushString(arena, size) \
10 (string8){ (u8 *)PushArray((arena), u8, (size)), (u64)(size) } 8 ({ \
9 string8 *result = PushStruct((arena), string8); \
10 result->data = PushArray((arena), u8, (size)); \
11 result->size = (u64)(size); \
12 result; \
13 })
14
15#define String8Cast(literal, literal_count) ( string8 ){( u8 * )( literal ),( u64 )( literal_count ) }
11 16
12#define StringFmt "%.*s" 17#define StringFmt "%.*s"
13#define ULongFmt "%lu" 18#define ULongFmt "%lu"
@@ -50,10 +55,8 @@ string8_append_char(string8 *buf, u8 c)
50read_only global_variable 55read_only global_variable
51string8 nil_string = 56string8 nil_string =
52{ 57{
53
54 .data = NULL, 58 .data = NULL,
55 .size = 0, 59 .size = 0,
56
57}; 60};
58 61
59#endif /* BASE_STRING_H */ 62#endif /* BASE_STRING_H */