From 9a443189203376a630ac205ca4654c7ceb796d5b Mon Sep 17 00:00:00 2001 From: 0x221E <0x221E@0xinfinity.dev> Date: Sun, 12 Apr 2026 15:47:30 +0200 Subject: Initial Commit --- string.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 string.h (limited to 'string.h') 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 + +#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 -- cgit v1.2.3