82 if (sb->
last != NULL) {
125 int len = vsnprintf(NULL, 0, fmt, args);
136 vsnprintf(buf, (
usize)len + 1, fmt, args);
168 MEM_COPY(buf + offset, n->string.str, n->string.size);
169 offset += n->string.size;
Context detection, compiler abstractions, utility macros, and data structures.
Sized UTF-8 string slices (String8) and manipulation utilities.
Core fixed-width type aliases and memory size constants.
#define ASSERT_NOT_NULL(ptr)
Asserts that a given pointer is not NULL.
#define function
File-scoped function (invisible to the linker).
#define C_LINKAGE_END
Closes a C linkage block for C++ compilers (Empty in C).
#define C_LINKAGE_BEGIN
Opens a C linkage block for C++ compilers (Empty in C).
#define MAKE_STRUCT(type, alloc)
Allocates and zero-initialises a single instance of type.
function void * mem_alloc(MemAllocator *alloc, usize size)
Allocator Helper Functions.
#define MEM_COPY(dst, src, size)
Copies memory using memmove (overlap-safe).
static void sb_append_cstr(StringBuilder *sb, MemAllocator *alloc, const char *cstr)
Appends a null-terminated C string to the builder.
static void sb_reset(StringBuilder *sb)
Resets the builder to empty without touching the allocator.
static void sb_append(StringBuilder *sb, MemAllocator *alloc, String8 str)
Appends a String8 slice to the builder.
static String8 sb_join(StringBuilder *sb, MemAllocator *out_alloc)
Materializes all appended segments into a single contiguous String8.
static void sb_append_fmt(StringBuilder *sb, MemAllocator *alloc, const char *fmt,...)
Appends a printf-style formatted string to the builder.
static String8 str8(u8 *str, usize size)
Creates a String8 from a raw pointer and explicit byte length.
static String8 str8_cstr(const char *cstr)
Converts a null-terminated C string into a String8.
Generic interface for abstracting memory allocators.
An abstract allocator interface.
A sized UTF-8 string slice.
A node for building singly-linked lists of strings.
struct String8Node * next
An allocator-agnostic string builder.