#include "sv.h" #include #include #include #include void sp_init(struct string_pool *sp) { assert(sp != NULL); sp->mem = (uintptr_t)malloc(1024*1024); sp->offset = 0; } struct string_view sv_create(struct string_pool *sp, const char *buf, size_t s) { assert(sp != NULL); if(buf == NULL) { printf("Error: cannot create string! Buffer null!"); exit(1); } char* ptr = (char*)sp->mem + sp->offset; memcpy((void*)ptr, buf, s); sp->offset += s; return (struct string_view) {.buf = ptr, .len = s}; }