Add: Discovery phase added

Add: StringPool, StringView
This commit is contained in:
0x221E
2026-01-16 16:44:30 +01:00
parent 58d405b397
commit 3829703102
10 changed files with 360 additions and 28 deletions

32
src/string.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef STRING_H
#define STRING_H
#include "memory.h"
#include <stddef.h>
#define SV(sp, s) string_create(sp, s, sizeof(s) - 1)
struct StringPool
{
Arena* a;
};
struct StringView
{
const char* buf;
size_t len;
};
typedef struct StringPool StringPool;
typedef struct StringView StringView;
StringPool string_pool_create(Arena* a);
void string_pool_reset(StringPool* sp);
StringView string_create(StringPool* sp, const char* s, size_t len);
// Ensure that lengths do not contain null term
StringView string_createcat_ss(StringPool* sp, StringView* a, StringView* b);
#endif