summaryrefslogtreecommitdiff
path: root/string.h
diff options
context:
space:
mode:
author0x221E <0x221E@0xinfinity.dev>2026-04-12 15:47:30 +0200
committer0x221E <0x221E@0xinfinity.dev>2026-04-12 15:47:30 +0200
commit9a443189203376a630ac205ca4654c7ceb796d5b (patch)
tree37b3494f1d3c58fecb6ad5a30c26d92b51634416 /string.h
Initial Commit
Diffstat (limited to 'string.h')
-rw-r--r--string.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/string.h b/string.h
new file mode 100644
index 0000000..17e6bc6
--- /dev/null
+++ b/string.h
@@ -0,0 +1,37 @@
+#ifndef STRING_H
+#define STRING_H
+
+#include <stddef.h>
+
+#define SV(sp, str) sv_create(sp, str, sizeof(str));
+
+struct StringView {
+ char *buf;
+ size_t len;
+};
+
+#define STRING_CONST {NULL, 0}
+
+struct StringPool {
+ void *mem;
+ size_t size;
+ size_t offset;
+};
+
+#define STRINGPOOL_CONST {NULL, 0, 0}
+
+typedef struct StringView StringView;
+typedef struct StringPool StringPool;
+
+void sp_init(StringPool *sp, size_t len);
+void* sp_reserve(StringPool *sp, size_t len);
+
+StringView sv_create(StringPool *sp, char *str, size_t len);
+StringView sv_concat_ss(StringPool *sp, StringView a, StringView b);
+StringView sv_concat_ss_n(StringPool *sp, int n, ...);
+
+StringView sv_sizet_to_string(StringPool *sp, size_t s);
+
+void sv_printf_cs(char *fmt, ...);
+
+#endif