StrInit
Description
Initialize a Str. Inside a Scope block the allocator argument may be omitted; the internal MisraScope allocator is used. Otherwise pass a typed allocator handle or a raw Allocator *.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Sys.c:244:
ValidateStr(err_str);
Allocator *alloc = StrAllocator(err_str);
Str out = StrInit(alloc);
StrAppendFmt(&out, "{} (errno {})", errno_description(eno), eno);
StrDeinit(err_str);- In
Log.c:54:
HeapAllocator h = HeapAllocatorInit();
Str full = StrInit(&h);
StrAppendFmt(&full, "[{}] [{}:{}] {}\n", (Zstr)NAMES[type], (Zstr)tag, line, (Zstr)msg);- In
Log.c:67:
StackFrame frames[32];
size n = CaptureStackTrace(frames, 32, 1);
Str trace = StrInit(&h);
// FormatStackTrace takes `Allocator *` -- legitimate erasure
// boundary; pass at the call site, no intermediate variable.
- In
Io.c:499:
// sense. Library-internal scratch keeps the debug-build instrumentation.
DefaultAllocator scratch = DefaultAllocatorInit();
Str tmp = StrInit(&scratch);
bool ok = str_append_fmt(&tmp, fmt, args, argc);
if (ok) {- In
Io.c:532:
}
out = StrInit(&scratch);
ok = str_append_fmt(&out, fmtstr, argv, argc);- In
Io.c:1072:
// DefaultAllocator: rendered size is caller-controlled (open-ended).
DefaultAllocator scratch = DefaultAllocatorInit();
Str tmp = StrInit(&scratch);
bool ok = render_binary_fmt(&tmp, fmtstr, argv, argc);
if (ok) {- In
Io.c:1102:
}
Str buffer = StrInit(&scratch);
i32 fd = FileFd(file);- In
Io.c:1336:
}
*out = StrInit(alloc);
if (!float_try_to_str(&canonical, value, alloc)) {- In
Io.c:1353:
u64 frac = 0;
result = StrInit(alloc);
if (StrBegin(&canonical)[0] == '-') {- In
Io.c:1432:
}
*out = StrInit(alloc);
if (!int_try_to_str(&digits, &value->significand, alloc)) {- In
Io.c:1438:
}
result = StrInit(alloc);
if (FloatIsZero(value)) {- In
Io.c:1642:
}
}
Str hex = StrInit(StrAllocator(o));
if (!StrFromU64(&hex, c, &config)) {
StrDeinit(&hex);- In
Io.c:1729:
}
}
Str hex = StrInit(StrAllocator(o));
StrIntFormat config = {.base = 16, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0};
if (!StrFromU64(&hex, (u8)xs[i], &config)) {- In
Io.c:1820:
// base-prefix / sign / padding logic from having to reach into
// `o`'s prefix bytes after the fact.
Str temp = StrInit(StrAllocator(o));
u8 base = 10;- In
Io.c:1921:
// base-prefix / sign / padding logic from having to reach into
// `o`'s prefix bytes after the fact.
Str temp = StrInit(StrAllocator(o));
u8 base = 10;- In
Io.c:2056:
// as the integer renderers: padding/sign accounting wants a
// self-contained slice it can measure.
Str temp = StrInit(StrAllocator(o));
u8 precision = fmt_info->flags & FMT_FLAG_HAS_PRECISION ? fmt_info->precision : 6;- In
Io.c:2863:
allocator_ptr = arg->allocator;
previous = *out;
temp = StrInit(allocator_ptr);
default_fmt = fmt_info ? *fmt_info :- In
Io.c:3272:
}
temp = StrInit(FloatAllocator(value));
parsed = FloatInit(FloatAllocator(value));- In
ArgParse.c:326:
// Usage line: "usage: name [OPTIONS] --req <REQ>... <POS>..."
Str usage = StrInit(self->alloc);
StrPushBackMany(&usage, "usage: ");
StrPushBackMany(&usage, self->name);- In
ArgParse.c:374:
n_specs = 64;
for (u64 i = 0; i < n_specs; ++i) {
left_col[i] = StrInit(self->alloc);
left_w[i] = spec_format_left(VecPtrAt(&self->specs, i), &left_col[i]);
if (left_w[i] > max_w)- In
Debug.c:283:
return;
}
Str rendered = StrInit(meta);
#if !defined(LOG_NO_BACKTRACE) || !LOG_NO_BACKTRACE
FormatStackTrace(&rendered, frames, count, meta);- In
BitVec.c:838:
}
*out = StrInit(alloc);
if (bv->length == 0) {
return true;- In
BitVec.c:851:
if (!StrPushBackR(out, bit_char)) {
StrDeinit(out);
*out = StrInit(alloc);
return false;
}- In
BitVec.c:863:
if (!bitvec_try_to_str(&result, bv, alloc)) {
result = StrInit(alloc);
}- In
Float.c:476:
ValidateFloat(out);
result = FloatInit(FloatAllocator(out));
digits = StrInit(FloatAllocator(out));
if (pos < length && (text[pos] == '+' || text[pos] == '-')) {- In
Float.c:617:
}
*out = StrInit(alloc);
if (FloatIsZero(value)) {- In
Float.c:627:
}
result = StrInit(alloc);
if (value->negative) {- In
Float.c:697:
if (!float_try_to_str(&result, value, alloc)) {
result = StrInit(alloc);
}- In
Str.c:96:
}
*out = StrInit(alloc);
if (len == 0) {
return true;- In
Str.c:112:
Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc) {
Str result = StrInit(alloc);
// Try-form leaves `result` empty-but-valid on OOM, so the caller
- In
Str.c:143:
MemSet(dst, 0, sizeof(Str));
*dst = StrInit(clone_allocator);
dst->copy_init = src->copy_init;
dst->copy_deinit = src->copy_deinit;- In
Str.c:979:
// Borrowed substring view: data points into the caller's bytes and
// capacity stays 0 so StrToU64 never tries to grow it.
Str temp_str = StrInit(str->allocator);
temp_str.data = str->data + pos;
temp_str.length = str->length - pos;- In
Int.c:674:
if (!int_try_to_str(&result, value, alloc)) {
result = StrInit(alloc);
}- In
Int.c:731:
}
*out = StrInit(alloc);
if (!int_validate_radix(radix)) {- In
Int.c:746:
}
result = StrInit(alloc);
while (!IntIsZero(¤t)) {- In
Int.c:783:
if (!int_try_to_str_radix(&result, value, radix, uppercase, alloc)) {
result = StrInit(alloc);
}- In
PdbCache.c:36:
// (1) exact CodeView path
*out_path = StrInit(StrAllocator(out_path));
StrPushBackMany(out_path, cv->pdb_path);
if (sys_path_exists(StrBegin(out_path)))- In
PdbCache.c:69:
return true;
Str pdb_path = StrInit(alloc);
if (!find_pdb(&entry->pe, StrBegin(&entry->module_path), &pdb_path)) {
StrDeinit(&pdb_path); // Returns true on success; `out` is populated with an opened Elf.
static bool try_open_sidecar(Zstr main_path, const Elf *main, Elf *out, Allocator *alloc) {
Str path = StrInit(alloc);
// (1) Build-ID
- In
Socket.c:458:
Str socket_addr_format(const SocketAddr *addr, Allocator *alloc) {
Str out = StrInit(alloc);
if (!addr || addr->length == 0) {
return out;- In
Proc.c:224:
PROCESS_INFORMATION pi = {0};
Str cmdline = StrInit(alloc);
StrPushBackMany(&cmdline, filepath);
for (char **arg = argv + 1; *arg; ++arg) {- In
ProcMaps.c:174:
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);- In
MachoCache.c:83:
}
Str path = StrInit(alloc);
if (!compose_dsym_path(StrBegin(&e->module_path), &path)) {
StrDeinit(&path);- In
Dns.c:155:
static void parse_hosts_table(HostsTable *table, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(HOSTS_FILE_PATH, &buf)) {
StrDeinit(&buf);- In
Dns.c:250:
static void parse_resolv_conf(DnsAddrs *out, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(RESOLV_CONF_FILE_PATH, &buf)) {
StrDeinit(&buf);- In
Http.c:43:
const HttpHeader *src = (const HttpHeader *)src_ptr;
dst->key = StrInit((Allocator *)alloc);
dst->value = StrInit((Allocator *)alloc);- In
Http.c:44:
dst->key = StrInit((Allocator *)alloc);
dst->value = StrInit((Allocator *)alloc);
if (!StrInitCopy(&dst->key, &src->key)) {- In
Http.c:115:
Allocator *alloc = req->allocator;
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);- In
Http.c:116:
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);
StrReadFmt(cursor, "{} {} {}\r\n", method, req->url, version);- In
Http.c:432:
response->content_type = content_type;
StrDeinit(&response->body);
response->body = StrInit(response->allocator);
if (FileReadAndClose(filepath, &response->body) < 0) {
LOG_ERROR("failed to read file: {}", filepath);- In
Http.c:454:
Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
Str out = StrInit(alloc);
if (!response) {- In
Http.c:491:
LOG_ERROR("HttpResponseSerialize: failed to append body");
StrDeinit(&out);
return StrInit(alloc);
}
}- In
KvConfig.c:283:
char c;
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));
StrIter read_si;- In
KvConfig.c:284:
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));
StrIter read_si;- In
KvConfig.c:359:
if (!value) {
return StrInit(MapAllocator(cfg));
}- In
KvConfig.c:369:
if (!value) {
return StrInit(MapAllocator(cfg));
}- In
JSON.c:54:
}
Str key = StrInit(&scratch);
// key start
- In
JSON.c:314:
// stack-backed buffer is unsafe -- DefaultAllocator is the right fit.
DefaultAllocator scratch = DefaultAllocatorInit();
Str ns = StrInit(&scratch);
bool is_neg = false;- In
JSON.c:640:
// valid input. DefaultAllocator is the right fit here.
DefaultAllocator scratch = DefaultAllocatorInit();
Str s = StrInit(&scratch);
si = JReadString(si, &s);
StrDeinit(&s);- In
Dwarf.c:547:
out->allocator = alloc;
out->entries = VecInitT(out->entries, alloc);
out->string_pool = StrInit(alloc);
const ElfSection *line_section = ElfFindSection(elf, ".debug_line");- In
DwarfInfo.c:526:
out->allocator = alloc;
out->entries = VecInitT(out->entries, alloc);
out->string_pool = StrInit(alloc);
if (!info_bytes || info_size == 0)- In
Pdb.c:707:
out->data = taken;
out->functions = VecInitT(out->functions, BufAllocator(&taken));
out->name_pool = StrInit(BufAllocator(&taken));
u32 num_dir_bytes = 0;- In
Dns.c:177:
// Decode one resource record. Advances the iter past the record.
static bool decode_record(BufIter *it, DnsRecord *rec, Allocator *alloc) {
rec->name = StrInit(alloc);
rec->target = StrInit(alloc);
rec->rdata = VecInitT(rec->rdata, alloc);- In
Dns.c:178:
static bool decode_record(BufIter *it, DnsRecord *rec, Allocator *alloc) {
rec->name = StrInit(alloc);
rec->target = StrInit(alloc);
rec->rdata = VecInitT(rec->rdata, alloc);
MemSet(rec->ipv4, 0, sizeof(rec->ipv4));- In
Dns.c:297:
// Skip echoed question section: each question is qname + qtype(2) + qclass(2).
for (u16 i = 0; i < qd; ++i) {
Str dummy = StrInit(alloc);
if (!decode_name(&it, &dummy)) {
StrDeinit(&dummy);- In
Beam.c:249:
static void log_request_summary(Zstr client_addr, Zstr prefix_bytes, size prefix_len) {
Scope(scope, DefaultAllocator) {
Str raw = StrInit(scope);
StrPushBackMany(&raw, prefix_bytes);- In
VecStr.c:27:
// treats as a fatal arg violation. An empty source clones to an
// empty fresh Str.
Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
*(Str *)dst_ptr = copy;- In
VecStr.c:46:
// Create Str with capacity
Str str = StrInit(alloc);
// Fill with data or generate simple pattern if not enough input
si = JSkipWhitespace(si); \
} \
Str key = StrInit(&alloc); \
UNPL(read_si) = JReadString(si, &key); \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
#define JR_STR(si, str) \
do { \
Str UNPL(my_str) = StrInit(&alloc); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \ do { \
if (!StrCmp(&key, (k))) { \
Str UNPL(my_str) = StrInit(&alloc); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \
JR_OBJ(si2, {
JR_ARR_KV(si2, "data", {
Str value = StrInit(&alloc);
JR_STR(si2, value);
VecPushBack(&data, value); Str name;
Str description;
} obj = {StrInit(&alloc), StrInit(&alloc)};
JR_OBJ(si, { Str message;
Str data;
} obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
JR_OBJ(si, { Str newline;
Str tab;
} obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
JR_OBJ(si, { i32 value;
bool flag;
} obj = {StrInit(&alloc), 0, false};
JR_OBJ(si, { bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove whitespace from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
struct {
bool success = true;
Str json = StrInit(&alloc);
struct {
bool success = true;
Str json = StrInit(&alloc);
ApiResponse response = { JW_OBJ_KV(json, "data", {
// Write dynamic key for source function ID
Str source_key = StrInit(&alloc);
u64 source_id = VecLen(&response.data) > 0 ? VecAt(&response.data, 0).source_function_id : 0;
StrAppendFmt(&source_key, "{}", source_id); if (VecLen(&response.data) > 0) {
AnnSymbol *s = &VecAt(&response.data, 0);
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", s->target_function_id);
bool success = true;
Str json = StrInit(&alloc);
Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit, &alloc);
bool success = true;
Str json = StrInit(&alloc);
SearchResult result = {0};
bool success = true;
Str json = StrInit(&alloc);
Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc); JW_OBJ_KV(json, "functions", {
VecForeach(&symbols, symbol) {
Str source_key = StrInit(&alloc);
StrAppendFmt(&source_key, "{}", symbol.source_function_id);
JW_OBJ_KV(json, StrBegin(&source_key), {
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", symbol.target_function_id);
bool success = true;
Str json = StrInit(&alloc);
// Create strings for the nested structure
bool success = true;
Str json = StrInit(&alloc);
Vec(u32) numbers = VecInit(&alloc); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
Str name = StrInitFromZstr("Alice", &alloc);
bool success = true;
Str json = StrInit(&alloc);
u32 count = 42;
bool success = true;
Str json = StrInit(&alloc);
bool enabled = true;
bool success = true;
Str json = StrInit(&alloc);
Person person = {1001, StrInitFromZstr("Bob", &alloc), 25, true, 50000.0};
bool success = true;
Str json = StrInit(&alloc);
Config config = {false, 30, StrInitFromZstr("INFO", &alloc)};
bool success = true;
Str json = StrInit(&alloc);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
bool success = true;
Str json = StrInit(&alloc);
struct {
bool success = true;
Str json = StrInit(&alloc);
SimpleProduct product = {0}; // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
// Write completely empty object
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_numbers = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
Str empty_name = StrInit(&alloc); Str json = StrInit(&alloc);
Str empty_name = StrInit(&alloc);
Str empty_desc = StrInit(&alloc);
Str empty_name = StrInit(&alloc);
Str empty_desc = StrInit(&alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
i32 temp = -25;
bool success = true;
Str json = StrInit(&alloc);
i64 big_int = 9223372036854775807LL;
bool success = true;
Str json = StrInit(&alloc);
i32 int_zero = 0;
bool success = true;
Str json = StrInit(&alloc);
// Note: These are the actual characters, not escape sequences
bool success = true;
Str json = StrInit(&alloc);
// These contain actual special characters that should be escaped
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_list = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_arr = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
i64 max_int = 2147483647LL;
bool success = true;
Str json = StrInit(&alloc);
f64 tiny = 0.000001;
bool success = true;
Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc); bool success = true;
Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc); Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc); Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc);
// Single integer
bool active;
f64 score;
} data = {0, StrInit(&alloc), false, 0.0};
JR_OBJ(si, { Str status;
} data = {
{0, {StrInit(&alloc), 0}},
StrInit(&alloc)
}; } data = {
{0, {StrInit(&alloc), 0}},
StrInit(&alloc)
}; } company;
} data = {
{{{StrInit(&alloc), 0, 0.0}}, StrInit(&alloc)}
}; // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = target_function_id; StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(&alloc), VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc)};
JR_OBJ(si, { // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
FunctionInfo info = {0};
info.name = StrInit(&alloc);
JR_OBJ(si, {
ModelInfo info = {0};
info.name = StrInit(&alloc);
JR_OBJ(si, {
SearchResult result = {0};
result.binary_name = StrInit(&alloc);
result.sha256 = StrInit(&alloc);
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc); SearchResult result = {0};
result.binary_name = StrInit(&alloc);
result.sha256 = StrInit(&alloc);
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
result.created_at = StrInit(&alloc); result.sha256 = StrInit(&alloc);
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
result.created_at = StrInit(&alloc);
result.model_name = StrInit(&alloc);
result.owned_by = StrInit(&alloc); result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
result.created_at = StrInit(&alloc);
result.model_name = StrInit(&alloc);
result.owned_by = StrInit(&alloc); result.created_at = StrInit(&alloc);
result.model_name = StrInit(&alloc);
result.owned_by = StrInit(&alloc);
JR_OBJ(si, { StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(&alloc), VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc)};
WriteFmt("[DEBUG] About to parse JSON...\n"); // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL); StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(&alloc), VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc)};
WriteFmt("[DEBUG] About to parse JSON...\n"); // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc); AnnSymbol sym = {0};
sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc); sym.analysis_name = StrInit(&alloc);
sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id; sym.function_name = StrInit(&alloc);
sym.sha256 = StrInit(&alloc);
sym.function_mangled_name = StrInit(&alloc);
sym.source_function_id = source_function_id;
sym.target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);- In
Read.Simple.c:70:
StrIter si = StrIterFromStr(json);
Str name = StrInit(&alloc);
Str city = StrInit(&alloc);- In
Read.Simple.c:71:
Str name = StrInit(&alloc);
Str city = StrInit(&alloc);
JR_OBJ(si, {
Person person = {0};
person.name = StrInit(&alloc);
JR_OBJ(si, {
Config config = {0};
config.log_level = StrInit(&alloc);
JR_OBJ(si, { JR_OBJ(si, {
JR_ARR_KV(si, "languages", {
Str lang = StrInit(&alloc);
JR_STR(si, lang);
VecPushBack(&languages, lang); bool active;
} data = {
{StrInit(&alloc), StrInit(&alloc)},
false
};
SimpleProduct product = {0};
product.name = StrInit(&alloc);
product.tags = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit, &alloc); JR_FLT_KV(si, "price", product.price);
JR_ARR_KV(si, "tags", {
Str tag = StrInit(&alloc);
JR_STR(si, tag);
VecPushBack(&product.tags, tag);- In
RoundTrip.c:105:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "count", original.count);- In
RoundTrip.c:121:
bool enabled;
Str message;
} parsed = {0, 0.0, false, StrInit(&alloc)};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:180:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "big_int", original.big_int);- In
RoundTrip.c:253:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_BOOL_KV(json, "flag1", original.flag1);- In
RoundTrip.c:306:
Str with_special;
} original = {
StrInit(&alloc),
StrInitFromZstr("hello", &alloc),
StrInitFromZstr("hello world with spaces", &alloc),- In
RoundTrip.c:313:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_STR_KV(json, "empty", original.empty);- In
RoundTrip.c:327:
Str with_spaces;
Str with_special;
} parsed = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:391:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });- In
RoundTrip.c:409:
});
JR_ARR_KV(si, "strings", {
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:479:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:491:
// Read back from JSON
TestPerson parsed_person = {0, StrInit(&alloc), 0, false, 0.0};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:561:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:584:
// Read back from JSON
ComplexData parsed = {0};
parsed.user = (TestPerson) {0, StrInit(&alloc), 0, false, 0.0};
parsed.config.debug_mode = true; // opposite of original
parsed.config.timeout = 0;- In
RoundTrip.c:587:
parsed.config.debug_mode = true; // opposite of original
parsed.config.timeout = 0;
parsed.config.log_level = StrInit(&alloc);
parsed.config.features = VecInitWithDeepCopyT(parsed.config.features, NULL, StrDeinit, &alloc);
parsed.numbers = VecInitT(parsed.numbers, &alloc);- In
RoundTrip.c:606:
JR_STR_KV(si, "log_level", parsed.config.log_level);
JR_ARR_KV(si, "features", {
Str feature = StrInit(&alloc);
JR_STR(si, feature);
VecPushBack(&parsed.config.features, feature);- In
RoundTrip.c:677:
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str empty_str = StrInit(&alloc);
// Write to JSON
- In
RoundTrip.c:680:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_STR_KV(json, "empty_string", empty_str);- In
RoundTrip.c:697:
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str parsed_str = StrInit(&alloc);
bool found_empty_object = false;- In
RoundTrip.c:709:
});
JR_ARR_KV(si, "empty_strings", {
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:763:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "max_int", original.max_int);- In
Parse.c:75:
Str src = StrInitFromZstr("host = localhost\n", &alloc);
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit(&alloc);
Str *stored_host = NULL;
bool result = true;- In
Http.c:40:
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);- In
Str.Memory.c:23:
Str s = StrInit(&alloc);
// Reserve more space than needed
- In
Str.Memory.c:105:
Str s = StrInit(&alloc);
// Reserve more space
- In
Str.Memory.c:188:
// Test with an empty string
StrDeinit(&s);
s = StrInit(&alloc);
// Reverse the string
- In
Backtrace.c:35:
size n = bt_capture_outer(frames, 32);
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, frames, n, alloc_base);- In
Backtrace.c:77:
ok = ok && VecLen(&frames) >= 2;
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, &frames, alloc_base);- In
Backtrace.c:107:
size n = bt_capture_outer(frames, 16);
Str out = StrInit(alloc_base);
FormatStackTraceWith(&out, frames, n, &res);- In
Backtrace.c:147:
size n = cfi_capture_outer(&res, frames, 32);
Str rendered = StrInit(alloc_base);
FormatStackTraceWith(&rendered, frames, n, &res);- In
Str.Convert.c:34:
Str s = StrInit(&alloc);
// Test decimal conversion
Str s = StrInit(&alloc);
// Test positive decimal conversion
Str s = StrInit(&alloc);
// Test integer conversion
for (size i = 0; i < sizeof(u64_values) / sizeof(u64_values[0]); i++) {
Str s = StrInit(&alloc);
// Test decimal round-trip
for (size i = 0; i < sizeof(i64_values) / sizeof(i64_values[0]); i++) {
Str s = StrInit(&alloc);
// Test decimal round-trip
for (size i = 0; i < sizeof(f64_values) / sizeof(f64_values[0]); i++) {
for (u8 precision = 1; precision <= 6; precision++) {
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false}; // Test base boundary conditions
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
// Test with base value itself
// Test extreme values
Str s = StrInit(&alloc);
// Test maximum u64
for (u8 precision = 1; precision <= 17; precision++) {
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};
for (size i = 0; i < sizeof(sci_values) / sizeof(sci_values[0]); i++) {
Str s = StrInit(&alloc);
// Force scientific notation
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = false}; // Test each base from 2 to 36
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
// Test StrFromU64
// Test uppercase digits for bases that use letters (11-36)
for (u8 base = 11; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = true, .use_prefix = false}; for (size i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) {
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = false, .use_prefix = false}; u64 test_value = i * 1000007; // Large prime multiplier
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromU64(&s, test_value, &config); f64 test_value = mantissa * F64Pow((10.0), (i32)(exp));
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};
StrFromF64(&s, test_value, &config);- In
Str.Access.c:24:
Str s = StrInit(&alloc);
bool result = (StrLen(&s) == 0);
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D p = {.x = 3, .y = 4};
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D p = {.x = -1, .y = 2};
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D src = {.x = 100, .y = -200};
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Bounds b = {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Bounds src = {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region r = {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region src = {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region region = {- In
AllocDebug.c:124:
// counted as a leak by the very report we're about to generate.
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);- In
Io.Read.c:323:
bool success = true;
Str s = StrInit(&alloc);
z = "Hello";
StrReadFmt(z, "{}", s);- In
Io.Read.c:368:
i32 num = 0;
Str name = StrInit(&alloc);
z = "Count: 42, Name: Alice";
StrReadFmt(z, "Count: {}, Name: {}", num, name);- In
Io.Read.c:575:
success = success && abc_pass;
Str str_val = StrInit(&alloc);
z = "Hello";
StrReadFmt(z, "{c}", str_val);- In
Io.Read.c:585:
StrDeinit(&str_val);
str_val = StrInit(&alloc);
z = "\"World\"";
StrReadFmt(z, "{cs}", str_val);- In
Io.Read.c:611:
// Test 1: :a (lowercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Io.Read.c:636:
// Test 1.1: :a (lowercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Io.Read.c:661:
// Test 2: :A (uppercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "hello world";- In
Io.Read.c:686:
// Test 2.1: :A (uppercase) conversion
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";- In
Io.Read.c:687:
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";- In
Io.Read.c:707:
// Test 2.2: :A (uppercase) conversion
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";- In
Io.Read.c:708:
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";- In
Io.Read.c:730:
// Test 3: :a with quoted string
{
Str result = StrInit(&alloc);
Zstr in = "\"MiXeD CaSe\"";- In
Io.Read.c:755:
// Test 4: :A with quoted string containing special characters
{
Str result = StrInit(&alloc);
Zstr in = "\"abc123XYZ\"";- In
Io.Read.c:780:
// Test 5: Regular :c format (no case conversion) for comparison
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Io.Read.c:892:
Int oct = IntInit(alloc_base);
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);- In
Io.Read.c:893:
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);- In
Io.Read.c:894:
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);- In
Io.Read.c:895:
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);
z = "123456789012345678901234567890";- In
Io.Read.c:943:
Float neg = FloatInit(alloc_base);
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);- In
Io.Read.c:944:
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);- In
Io.Read.c:945:
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);
z = "1234567890.012345"; Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));
bool result = FloatToInt(&result_value, &value);- In
Io.Write.c:35:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:63:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:103:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:175:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:196:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:213:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:230:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:252:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:278:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:305:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:343:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:367:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:527:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:591:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;- In
Io.Write.c:637:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;
Float exact = FloatFromStr("1234567890.012345", alloc_base);- In
Io.Write.c:675:
bool test_str_write_fmt_clears(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "old prefix ");
StrWriteFmt(&s, "fresh {}", LVAL(42));- In
Io.Write.c:690:
bool test_str_patch_fmt(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "AAAAAAAA");
size before_length = StrLen(&s);- In
Float.Math.c:31:
Float value = FloatFromStr("12.5", &alloc.base);
Str text = StrInit(&alloc.base);
FloatNegate(&value);- In
Float.Math.c:57:
Float b = FloatFromStr("0.03", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Float.Math.c:80:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Float.Math.c:104:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Float.Math.c:152:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Float.Math.c:175:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Float.Math.c:199:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Float.Math.c:242:
Float b = FloatFromStr("-0.2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Float.Math.c:265:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Float.Math.c:289:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Float.Math.c:332:
Float b = FloatFromStr("8", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 3);- In
Float.Math.c:355:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 0);- In
Float.Math.c:379:
Int whole = IntFrom(3, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 1);- In
Int.Math.c:104:
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntAdd(&result_value, &a, &b);- In
Int.Math.c:129:
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);
IntAdd(&result_value, &base, &rhs);- In
Int.Math.c:182:
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);
bool result = IntSub(&result_value, &base, &rhs);- In
Int.Math.c:256:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntMul(&result_value, &value, 25u);- In
Int.Math.c:317:
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntPow(&result_value, &base, 20u);- In
Int.Math.c:344:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
IntDivMod("ient, &remainder, ÷nd, 97u);- In
Int.Math.c:385:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool result = IntDivExact(&result_value, ÷nd, 90u);- In
Int.Math.c:425:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntDivMod("ient, &remainder, ÷nd, 97);- In
Int.Math.c:895:
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
File.c:50:
}
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:84:
}
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
Str.Type.c:27:
// Create a Str object
Str s = StrInit(&alloc);
// Check that it behaves like a Vec of chars
- In
Str.Type.c:83:
// Create a valid Str
Str s = StrInit(&alloc);
// This should not crash
- In
Str.Type.c:128:
// Create an invalid Str by corrupting its fields
Str s = StrInit(&alloc);
// Corrupt the string to make it invalid
- In
Str.Init.c:24:
// Test StrInit function
bool test_str_init(void) {
WriteFmt("Testing StrInit\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Str.Init.c:28:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
// Validate the string
- In
Str.Init.c:151:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "Hello, {}!", &"World"[0]);- In
Str.Init.c:200:
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrInit(&alloc);
// Copy src to dst
- In
Str.Init.c:227:
Str dup = StrInitFromStr(&src, &alloc);
Str dst = StrInit(&alloc);
bool copied = StrInitCopy(&dst, &src);- In
Str.Foreach.c:42:
// Build a new string by iterating through each character with its index
Str result = StrInit(&alloc);
StrForeachIdx(&s, chr, idx) {
StrAppendFmt(&result, "{c}{}", chr, idx);- In
Str.Foreach.c:65:
// Build a new string by iterating through each character in reverse with its index
Str result = StrInit(&alloc);
StrForeachReverseIdx(&s, chr, idx) {- In
Str.Foreach.c:90:
// Build a new string by iterating through each character pointer with its index
Str result = StrInit(&alloc);
StrForeachPtrIdx(&s, chrptr, idx) {
// Append the character (via pointer) and its index to the result string
// Build a new string by iterating through each character pointer in reverse with its index
Str result = StrInit(&alloc);
StrForeachReversePtrIdx(&s, chrptr, idx) {
// Build a new string by iterating through each character
Str result = StrInit(&alloc);
StrForeach(&s, chr) {
// Append the character to the result string
// Build a new string by iterating through each character in reverse
Str result = StrInit(&alloc);
size char_count = 0;
// Build a new string by iterating through each character pointer
Str result = StrInit(&alloc);
StrForeachPtr(&s, chrptr) {
// Append the character (via pointer) to the result string
// Build a new string by iterating through each character pointer in reverse
Str result = StrInit(&alloc);
size char_count = 0;
// Build a new string by iterating through a range of characters with indices
Str result = StrInit(&alloc);
StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
// Append the character and its index to the result string
// Test with empty range
Str empty_result = StrInit(&alloc);
StrForeachInRangeIdx(&s, chr, idx, 3, 3) {
// This block should not execute
// Build a new string by iterating through a range of characters
Str result = StrInit(&alloc);
StrForeachInRange(&s, chr, 0, 5) {
// Append the character to the result string
// Test with range at the end of the string
Str end_result = StrInit(&alloc);
StrForeachInRange(&s, chr, 6, 11) {
// Append the character to the result string
// Build a new string by iterating through a range of character pointers with indices
Str result = StrInit(&alloc);
StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
// Append the character and its index to the result string
// Build a new string by iterating through a range of character pointers
Str result = StrInit(&alloc);
StrForeachPtrInRange(&s, chrptr, 0, 5) {
// Append the character to the result string
- In
ArgParse.c:250:
ArgParse p = ArgParseInit("prog", NULL, &a);
Str name = StrInit(&a);
ArgOptional(&p, NULL, "--name", &name, "n");- In
Log.h:43:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:67:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:90:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:125:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Log.h:154:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Log.h:182:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Proc.h:286:
#define ProcReadFromStdoutFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
ProcReadFromStdout((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \- In
Proc.h:313:
#define ProcReadFromStderrFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
ProcReadFromStderr((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \- In
Proc.h:340:
#define ProcWriteToStdinFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
StrAppendFmt(&UNPL(buf), __VA_ARGS__); \
ProcWriteToStdin((p), &UNPL(buf)); \- In
Proc.h:365:
#define ProcWriteToStdinFmtLn(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
StrAppendFmt(&UNPL(buf), __VA_ARGS__); \
StrPushBackR(&UNPL(buf), '\n'); \- In
JSON.h:249:
#define JR_STR(si, str) \
do { \
Str UNPL(my_str) = StrInit(); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \- In
JSON.h:272:
do { \
if (!StrCmp(&key, (k))) { \
Str UNPL(my_str) = StrInit(); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \
- In
JSON.h:570:
\
\
Str key = StrInit(); \
\
/* key start */ \
Last updated on