StringPool :: struct {
arena: Arena
}
Many times, storing strings is annoying because you need to keep the data alive, while moving pointers around and changing them.
To remedy this, a StringPool is a simple wrapper around an arena allocator that enables you to quickly copy a string to the pool. From there, you can use the string until the pool is cleared or freed.
StringPool.add :: (sp: &StringPool, s: [] u8) -> [] u8
Copies a string into the pool, returning the copied string.
StringPool.flush :: (sp: &StringPool) -> void
Clears all entries in the pool.
StringPool.free :: (sp: &StringPool) -> void
Completely frees all memory in the pool.
StringPool.make :: (maximum_string_length: i32, allocator: Allocator) -> StringPool
String_Buffer :: struct {
data: [&] u8
count: u32
capacity: u32
}
buffer_append :: (buffer: &String_Buffer, end: [] u8) -> bool
buffer_clear :: (buffer: &String_Buffer) -> void
buffer_delete :: (buffer: &String_Buffer, position: i32) -> bool
buffer_insert :: (buffer: &String_Buffer, position: i32, ch: u8) -> bool
buffer_make :: (buffer_memory: [] u8, initial_str: [] u8) -> String_Buffer
buffer_to_str :: (buffer: &String_Buffer) -> [] u8
from_cstr :: (s: [&] u8) -> [] u8
is_empty :: (s: [] u8) -> bool
length :: (s: [] u8) -> u32
length :: (s: [&] u8) -> u32
pool_add :: (sp: &StringPool, s: [] u8) -> [] u8
Copies a string into the pool, returning the copied string.
pool_flush :: (sp: &StringPool) -> void
Clears all entries in the pool.
pool_free :: (sp: &StringPool) -> void
Completely frees all memory in the pool.
pool_make :: (maximum_string_length: i32, allocator: Allocator) -> StringPool