Add: Discovery phase added
Add: StringPool, StringView
This commit is contained in:
32
src/string.h
Normal file
32
src/string.h
Normal 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
|
||||
Reference in New Issue
Block a user