Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.debug
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memwatch
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.crypto
core.crypto.keys
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.encoding.xml
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core.string

StringPool
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.

Methods
StringPool.add
StringPool.add :: (sp: &StringPool, s: [] u8) -> [] u8

Copies a string into the pool, returning the copied string.

StringPool.flush
StringPool.flush :: (sp: &StringPool) -> void

Clears all entries in the pool.

StringPool.free
StringPool.free :: (sp: &StringPool) -> void

Completely frees all memory in the pool.

StringPool.make
StringPool.make :: (maximum_string_length: i32, allocator: Allocator) -> StringPool

Creates a StringPool.

String_Buffer
String_Buffer :: struct {
    data: [&] u8
    count: u32
    capacity: u32
}
buffer_append
buffer_append :: (buffer: &String_Buffer, end: [] u8) -> bool
buffer_clear
buffer_clear :: (buffer: &String_Buffer) -> void
buffer_delete
buffer_delete :: (buffer: &String_Buffer, position: i32) -> bool
buffer_insert
buffer_insert :: (buffer: &String_Buffer, position: i32, ch: u8) -> bool
buffer_make
buffer_make :: (buffer_memory: [] u8, initial_str: [] u8) -> String_Buffer
buffer_to_str
buffer_to_str :: (buffer: &String_Buffer) -> [] u8
from_cstr
from_cstr :: (s: [&] u8) -> [] u8
is_empty
is_empty :: (s: [] u8) -> bool
length
length :: (s: [] u8) -> u32
length :: (s: [&] u8) -> u32
pool_add
pool_add :: (sp: &StringPool, s: [] u8) -> [] u8

Copies a string into the pool, returning the copied string.

pool_flush
pool_flush :: (sp: &StringPool) -> void

Clears all entries in the pool.

pool_free
pool_free :: (sp: &StringPool) -> void

Completely frees all memory in the pool.

pool_make
pool_make :: (maximum_string_length: i32, allocator: Allocator) -> StringPool

Creates a StringPool.