Skip to content

StrDeinit

Description

Release the backing storage of str through its inline allocator and zero the handle so a later double-Deinit is a no-op.

Success

Returns to the caller. *str is zeroed.

Failure

Function cannot fail. NULL str is a no-op.

Usage example (Cross-references)

Usage examples (Cross-references)
        Str        out   = StrInit(alloc);
        StrAppendFmt(&out, "{} (errno {})", errno_description(eno), eno);
        StrDeinit(err_str);
        *err_str = out;
        return err_str;
            FormatStackTrace(&trace, frames, n, ALLOCATOR_OF(&h));
            (void)FileWrite(&out, StrBegin(&trace), StrLen(&trace));
            StrDeinit(&trace);
        }
    #else
    #endif
    
        StrDeinit(&full);
        HeapAllocatorDeinit(&h);
    }
            }
        }
        StrDeinit(&tmp);
        DefaultAllocatorDeinit(&scratch);
        return ok;
        }
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&scratch);
        return ok;
            }
        }
        StrDeinit(&tmp);
        DefaultAllocatorDeinit(&scratch);
        return ok;
            if (end_pos < 0) {
                LOG_ERROR("FileSeek(END) failed during f_read_fmt");
                StrDeinit(&buffer);
                DefaultAllocatorDeinit(&scratch);
                return;
                if (got < 0) {
                    LOG_ERROR("FileRead failed during f_read_fmt");
                    StrDeinit(&buffer);
                    DefaultAllocatorDeinit(&scratch);
                    return;
        }
    
        StrDeinit(&buffer);
        DefaultAllocatorDeinit(&scratch);
    }
                }
    
                StrDeinit(&canonical);
                *out = result;
                return true;
            }
    
            StrDeinit(&canonical);
            *out = result;
            return true;
    
    fail:
        StrDeinit(&canonical);
        StrDeinit(&result);
        return false;
    fail:
        StrDeinit(&canonical);
        StrDeinit(&result);
        return false;
    }
                goto fail;
            }
            StrDeinit(&digits);
            *out = result;
            return true;
            goto fail;
        }
        StrDeinit(&digits);
        *out = result;
        return true;
    
    fail:
        StrDeinit(&digits);
        StrDeinit(&result);
        return false;
    fail:
        StrDeinit(&digits);
        StrDeinit(&result);
        return false;
    }
                    Str hex = StrInit(StrAllocator(o));
                    if (!StrFromU64(&hex, c, &config)) {
                        StrDeinit(&hex);
                        return false;
                    }
                    if (StrLen(&hex) == 1) {
                        if (!StrPushFrontR(&hex, '0')) {
                            StrDeinit(&hex);
                            return false;
                        }
                    }
                    if (!StrPushBackMany(o, "0x") || !StrMerge(o, &hex)) {
                        StrDeinit(&hex);
                        return false;
                    }
                        return false;
                    }
                    StrDeinit(&hex);
                }
            } else {
                    StrIntFormat config = {.base = 16, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0};
                    if (!StrFromU64(&hex, (u8)xs[i], &config)) {
                        StrDeinit(&hex);
                        return false;
                    }
                    if (StrLen(&hex) == 1) {
                        if (!StrPushFrontR(&hex, '0')) {
                            StrDeinit(&hex);
                            return false;
                        }
                    }
                    if (!StrPushBackMany(o, "0x") || !StrMerge(o, &hex)) {
                        StrDeinit(&hex);
                        return false;
                    }
                        return false;
                    }
                    StrDeinit(&hex);
                    i++;
                }
        StrIntFormat config = {.base = base, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0, .use_prefix = use_prefix};
        if (!StrFromU64(&temp, *v, &config)) {
            StrDeinit(&temp);
            return false;
        }
    
        if (!StrMerge(o, &temp)) {
            StrDeinit(&temp);
            return false;
        }
            return false;
        }
        StrDeinit(&temp);
    
        if (fmt_info->width > 0) {
        StrIntFormat config = {.base = base, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0, .use_prefix = use_prefix};
        if (!StrFromI64(&temp, *v, &config)) {
            StrDeinit(&temp);
            return false;
        }
    
        if (!StrMerge(o, &temp)) {
            StrDeinit(&temp);
            return false;
        }
            return false;
        }
        StrDeinit(&temp);
    
        if (fmt_info->width > 0) {
            };
            if (!StrFromF64(&temp, *v, &config)) {
                StrDeinit(&temp);
                return false;
            }
    
            if (!StrMerge(o, &temp)) {
                StrDeinit(&temp);
                return false;
            }
                return false;
            }
            StrDeinit(&temp);
        }
    
        if (!StrMerge(o, &temp)) {
            StrDeinit(&temp);
            return false;
        }
            return false;
        }
        StrDeinit(&temp);
    
        if (fmt_info->width > 0) {
                    char c    = ZstrProcessEscape(&curr);
                    if (c == 0) {
                        StrDeinit(s);
                        return NULL;
                    }
                    char c    = ZstrProcessEscape(&curr);
                    if (c == 0) {
                        StrDeinit(s);
                        return NULL;
                    }
        if (quote) {
            LOG_ERROR("Unterminated quoted string");
            StrDeinit(s);
            return NULL;
        }
            // the digit-by-digit scan below.
            if (StrToF64(&temp, v, NULL)) {
                StrDeinit(&temp);
                DefaultAllocatorDeinit(&scratch);
                return StrIterDataAt(&si, StrIterIndex(&si));
                return StrIterDataAt(&si, StrIterIndex(&si));
            }
            StrDeinit(&temp);
    
            si = saved;
        if (!is_valid_numeric_string(&temp, true)) {
            LOG_ERROR("Invalid floating point format");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
        if (!StrToF64(&temp, v, NULL)) {
            LOG_ERROR("Failed to parse f64");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
        }
    
        StrDeinit(&temp);
        DefaultAllocatorDeinit(&scratch);
        return start + pos;
             StrBegin(&temp)[1] == 'B' || StrBegin(&temp)[1] == 'o' || StrBegin(&temp)[1] == 'O')) {
            LOG_ERROR("Incomplete number format");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
        if (!is_valid_numeric_string(&temp, false)) {
            LOG_ERROR("Invalid numeric format");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
        if (!StrToU64(&temp, &val, NULL)) {
            LOG_ERROR("Failed to parse u8");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
        if (val > UINT8_MAX) {
            LOG_ERROR("Value {} exceeds u8 maximum ({})", val, UINT8_MAX);
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
    
        *v = (u8)val;
        StrDeinit(&temp);
        DefaultAllocatorDeinit(&scratch);
        return start + pos;
                 StrBegin(&temp)[1] == 'B' || StrBegin(&temp)[1] == 'o' || StrBegin(&temp)[1] == 'O')) {                   \
                LOG_ERROR("Incomplete number format");                                                                     \
                StrDeinit(&temp);                                                                                          \
                DefaultAllocatorDeinit(&scratch);                                                                          \
                return start;                                                                                              \
            if (!is_valid_numeric_string(&temp, false)) {                                                                  \
                LOG_ERROR("Invalid numeric format");                                                                       \
                StrDeinit(&temp);                                                                                          \
                DefaultAllocatorDeinit(&scratch);                                                                          \
                return start;                                                                                              \
            if (!PARSER(&temp, &val, NULL)) {                                                                              \
                LOG_ERROR("Failed to parse " #NAME);                                                                       \
                StrDeinit(&temp);                                                                                          \
                DefaultAllocatorDeinit(&scratch);                                                                          \
                return start;                                                                                              \
                                                                                                                           \
            *v = (T)val;                                                                                                   \
            StrDeinit(&temp);                                                                                              \
            DefaultAllocatorDeinit(&scratch);                                                                              \
            return start + pos;                                                                                            \
        if (val > UMAX) {                                                                                                  \
            LOG_ERROR("Value {} exceeds " #NAME " maximum ({})", val, UMAX);                                               \
            StrDeinit(&temp);                                                                                              \
            DefaultAllocatorDeinit(&scratch);                                                                              \
            return start;                                                                                                  \
        if (val > IMAX || val < IMIN) {                                                                                    \
            LOG_ERROR("Value {} outside " #NAME " range ({} to {})", val, IMIN, IMAX);                                     \
            StrDeinit(&temp);                                                                                              \
            DefaultAllocatorDeinit(&scratch);                                                                              \
            return start;                                                                                                  \
        next = _read_Str(i, &default_fmt, &temp);
        if (next == i) {
            StrDeinit(&temp);
            return i;
        }
        if (!result) {
            LOG_ERROR("Failed to allocate memory for string");
            StrDeinit(&temp);
            return i;
        }
    
        *out = result;
        StrDeinit(&temp);
        return next;
    }
                }
                if (!StrMerge(o, &bit_str)) {
                    StrDeinit(&bit_str);
                    return false;
                }
                    return false;
                }
                StrDeinit(&bit_str);
            }
        }
    
        if (!StrMerge(o, &temp)) {
            StrDeinit(&temp);
            return false;
        }
            return false;
        }
        StrDeinit(&temp);
    
        if (fmt_info->width > 0) {
            if (!StrToU64(&hex_str, &value, &config)) {
                LOG_ERROR("Failed to parse hex value");
                StrDeinit(&hex_str);
                return start;
            }
    
            *bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
            StrDeinit(&hex_str);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
            if (!StrToU64(&oct_str, &value, &config)) {
                LOG_ERROR("Failed to parse octal value");
                StrDeinit(&oct_str);
                return start;
            }
    
            *bv = BitVecFromInteger(value, bit_len, BitVecAllocator(bv));
            StrDeinit(&oct_str);
            return StrIterDataAt(&si, StrIterIndex(&si));
        }
        *bv = BitVecFromStr(StrBegin(&bin_str), BitVecAllocator(bv));
    
        StrDeinit(&bin_str);
        return StrIterDataAt(&si, StrIterIndex(&si));
    }
    
        if (!ok) {
            StrDeinit(&temp);
            return start;
        }
        *value = parsed;
    
        StrDeinit(&temp);
        return StrIterDataAt(&si, StrIterIndex(&si));
    }
        if (float_fmt_uses_unsupported_flags(fmt_info)) {
            LOG_ERROR("Float only supports decimal and scientific reading");
            StrDeinit(&temp);
            FloatDeinit(&parsed);
            return i;
        if (!StrIterRemainingLength(&si)) {
            LOG_ERROR("Failed to parse Float: empty input");
            StrDeinit(&temp);
            FloatDeinit(&parsed);
            return StrIterDataAt(&si, StrIterIndex(&si));
        if (token_len == 0) {
            LOG_ERROR("Failed to parse Float");
            StrDeinit(&temp);
            FloatDeinit(&parsed);
            return start;
        }
    
        StrDeinit(&temp);
        temp = StrInitFromCstr(start, token_len, FloatAllocator(value));
        if (!FloatTryFromStr(&parsed, StrBegin(&temp))) {
        temp = StrInitFromCstr(start, token_len, FloatAllocator(value));
        if (!FloatTryFromStr(&parsed, StrBegin(&temp))) {
            StrDeinit(&temp);
            FloatDeinit(&parsed);
            return start;
        *value = parsed;
    
        StrDeinit(&temp);
        return start + token_len;
    }
            if (StrToF64(&temp, &val, NULL)) {
                *v = (f32)val;
                StrDeinit(&temp);
                DefaultAllocatorDeinit(&scratch);
                return StrIterDataAt(&si, StrIterIndex(&si));
                return StrIterDataAt(&si, StrIterIndex(&si));
            }
            StrDeinit(&temp);
    
            si = saved;
        if (!is_valid_numeric_string(&temp, true)) {
            LOG_ERROR("Invalid floating point format");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
        if (!StrToF64(&temp, &val, NULL)) {
            LOG_ERROR("Failed to parse f32");
            StrDeinit(&temp);
            DefaultAllocatorDeinit(&scratch);
            return start;
    
        *v = (f32)val;
        StrDeinit(&temp);
        DefaultAllocatorDeinit(&scratch);
        return start + pos;
    
        FWriteFmtLn(&err, "{}", usage);
        StrDeinit(&usage);
        FWriteFmtLn(&err, "");
    
        for (u64 i = 0; i < n_specs; ++i) {
            StrDeinit(&left_col[i]);
        }
    }
    #endif
        LOG_ERROR("    {} trace:\n{}", label, rendered);
        StrDeinit(&rendered);
    }
            char bit_char = BitVecGet(bv, i) ? '1' : '0';
            if (!StrPushBackR(out, bit_char)) {
                StrDeinit(out);
                *out = StrInit(alloc);
                return false;
        }
    
        StrDeinit(&bv_str);
        return result;
    }
        }
    
        StrDeinit(&bv_str);
        return result;
    }
        result.exponent = explicit_exp - fractional;
    
        StrDeinit(&digits);
        float_normalize(&result);
        FloatDeinit(out);
    
    fail:
        StrDeinit(&digits);
        FloatDeinit(&result);
        return false;
        }
    
        StrDeinit(&digits);
        *out = result;
        return true;
    
    fail:
        StrDeinit(&digits);
        StrDeinit(&result);
        return false;
    fail:
        StrDeinit(&digits);
        StrDeinit(&result);
        return false;
    }
    }
    
    void StrDeinit(Str *copy) {
        ValidateStr(copy);
        deinit_vec(GENERIC_VEC(copy), sizeof(char));
    void str_deinit(void *copy, const Allocator *alloc) {
        (void)alloc;
        StrDeinit((Str *)copy);
    }
                IntDeinit(&quotient);
                IntDeinit(&current);
                StrDeinit(&result);
                return false;
            }
        Str pdb_path = StrInit(alloc);
        if (!find_pdb(&entry->pe, StrBegin(&entry->module_path), &pdb_path)) {
            StrDeinit(&pdb_path);
            return false;
        }
        }
        bool ok = PdbOpen(&entry->pdb, &pdb_path, alloc);
        StrDeinit(&pdb_path);
        if (!ok)
            return false;
    
        if (!VecPushBackR(&self->entries, entry)) {
            StrDeinit(&entry.module_path);
            return NULL;
        }
            if (e->pe_open)
                PeDeinit(&e->pe);
            StrDeinit(&e->module_path);
        }
        VecDeinit(&self->entries);
            if (sys_path_exists(StrBegin(&path)) && ElfOpen(out, &path, alloc)) {
                if (sidecar_matches(main, out, /*by_build_id*/ true)) {
                    StrDeinit(&path);
                    return true;
                }
            if (sys_path_exists(StrBegin(&path)) && ElfOpen(out, &path, alloc)) {
                if (sidecar_matches(main, out, /*by_build_id*/ false)) {
                    StrDeinit(&path);
                    return true;
                }
            if (sys_path_exists(StrBegin(&path)) && ElfOpen(out, &path, alloc)) {
                if (sidecar_matches(main, out, /*by_build_id*/ false)) {
                    StrDeinit(&path);
                    return true;
                }
            if (sys_path_exists(StrBegin(&path)) && ElfOpen(out, &path, alloc)) {
                if (sidecar_matches(main, out, /*by_build_id*/ false)) {
                    StrDeinit(&path);
                    return true;
                }
        }
    
        StrDeinit(&path);
        return false;
    }
        if (!CreateProcessA(NULL, StrBegin(&cmdline), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
            LOG_ERROR("CreateProcessA() failed (GetLastError={})", (i32)GetLastError());
            StrDeinit(&cmdline);
            CloseHandle(hStdinRead);
            CloseHandle(hStdinWrite);
            return proc;
        }
        StrDeinit(&cmdline);
    
        CloseHandle(hStdinRead);
        if (!self)
            return;
        StrDeinit(&self->raw);
        VecDeinit(&self->entries);
        MemSet(self, 0, sizeof(*self));
        }
    
        StrDeinit(&copy->name);
        copy->type = 0;
    
        if (!VecPushBackR(&self->entries, entry)) {
            StrDeinit(&entry.module_path);
            return NULL;
        }
        Str path = StrInit(alloc);
        if (!compose_dsym_path(StrBegin(&e->module_path), &path)) {
            StrDeinit(&path);
            return false;
        }
        }
        if (!sys_path_exists(StrBegin(&path)) || !MachoOpen(&e->dsym, &path, alloc)) {
            StrDeinit(&path);
            return false;
        }
            return false;
        }
        StrDeinit(&path);
    
        if (!MachoHasUuid(&e->dsym) || MemCompare(MachoUuid(&e->dsym), MachoUuid(&e->main), 16) != 0) {
            if (e->main_open)
                MachoDeinit(&e->main);
            StrDeinit(&e->module_path);
        }
        VecDeinit(&self->entries);
        Str buf = StrInit(alloc);
        if (!slurp_file(HOSTS_FILE_PATH, &buf)) {
            StrDeinit(&buf);
            return;
        }
                    // failure ownership of `e.name` stays with us. Release
                    // it to avoid leaking the cstr allocation.
                    StrDeinit(&e.name);
                    break;
                }
        }
    
        StrDeinit(&buf);
    }
        Str buf = StrInit(alloc);
        if (!slurp_file(RESOLV_CONF_FILE_PATH, &buf)) {
            StrDeinit(&buf);
            return;
        }
        }
    
        StrDeinit(&buf);
    }
        if (VecBegin(&self->hosts)) {
            VecForeachPtr(&self->hosts, e) {
                StrDeinit(&e->name);
            }
            VecDeinit(&self->hosts);
            LOG_FATAL("invalid arguments");
        }
        StrDeinit(&header->key);
        StrDeinit(&header->value);
        MemSet(header, 0, sizeof(*header));
        }
        StrDeinit(&header->key);
        StrDeinit(&header->value);
        MemSet(header, 0, sizeof(*header));
    }
        (void)alloc; // each Str carries its own allocator handle
        HttpHeader *header = (HttpHeader *)header_ptr;
        StrDeinit(&header->key);
        StrDeinit(&header->value);
        MemSet(header, 0, sizeof(*header));
        HttpHeader *header = (HttpHeader *)header_ptr;
        StrDeinit(&header->key);
        StrDeinit(&header->value);
        MemSet(header, 0, sizeof(*header));
    }
    
        if (!StrInitCopy(&dst->key, &src->key)) {
            StrDeinit(&dst->key);
            return false;
        }
        }
        if (!StrInitCopy(&dst->value, &src->value)) {
            StrDeinit(&dst->key);
            StrDeinit(&dst->value);
            return false;
        if (!StrInitCopy(&dst->value, &src->value)) {
            StrDeinit(&dst->key);
            StrDeinit(&dst->value);
            return false;
        }
        if (cursor == in) {
            LOG_ERROR("http request parse failed: invalid request line");
            StrDeinit(&method);
            StrDeinit(&version);
            return in;
            LOG_ERROR("http request parse failed: invalid request line");
            StrDeinit(&method);
            StrDeinit(&version);
            return in;
        }
        if (0 != ZstrCompareN(StrBegin(&version), "HTTP/1.1", 8)) {
            LOG_ERROR("invalid/unsupported HTTP version");
            StrDeinit(&method);
            StrDeinit(&version);
            return in;
            LOG_ERROR("invalid/unsupported HTTP version");
            StrDeinit(&method);
            StrDeinit(&version);
            return in;
        }
            return in;
        }
        StrDeinit(&version);
    
        req->method = http_request_method_from_str(&method);
    
        req->method = http_request_method_from_str(&method);
        StrDeinit(&method);
        if (req->method == HTTP_REQUEST_METHOD_UNKNOWN) {
            LOG_ERROR("invalid http request method");
            LOG_FATAL("invalid arguments");
        }
        StrDeinit(&req->url);
        VecDeinit(&req->headers);
        MemSet(req, 0, sizeof(*req));
        response->status_code  = status;
        response->content_type = HTTP_CONTENT_TYPE_TEXT_HTML;
        StrDeinit(&response->body);
        response->body = StrDup(html, response->allocator);
        return response;
        response->status_code  = status;
        response->content_type = content_type;
        StrDeinit(&response->body);
        response->body = StrInit(response->allocator);
        if (FileReadAndClose(filepath, &response->body) < 0) {
            if (!StrPushBackMany(&out, StrBegin(&response->body), StrLen(&response->body))) {
                LOG_ERROR("HttpResponseSerialize: failed to append body");
                StrDeinit(&out);
                return StrInit(alloc);
            }
            LOG_FATAL("invalid arguments");
        }
        StrDeinit(&response->body);
        VecDeinit(&response->headers);
        MemSet(response, 0, sizeof(*response));
        if (StrLen(value) > 0) {
            Str stripped = StrStrip(value, NULL);
            StrDeinit(value);
            *value = stripped;
        }
    
            if (!StrIterPeek(&si, &c)) {
                StrDeinit(&key);
                StrDeinit(&value);
                break;
            if (!StrIterPeek(&si, &c)) {
                StrDeinit(&key);
                StrDeinit(&value);
                break;
            }
            if (kvconfig_is_comment_start(c)) {
                si = KvConfigSkipLine(si);
                StrDeinit(&key);
                StrDeinit(&value);
                continue;
                si = KvConfigSkipLine(si);
                StrDeinit(&key);
                StrDeinit(&value);
                continue;
            }
            read_si = KvConfigReadPair(si, &key, &value);
            if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
                StrDeinit(&key);
                StrDeinit(&value);
                return saved_si;
            if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
                StrDeinit(&key);
                StrDeinit(&value);
                return saved_si;
            }
    
            MapSetOnlyL(cfg, key, value);
            StrDeinit(&key);
            StrDeinit(&value);
            si = read_si;
            MapSetOnlyL(cfg, key, value);
            StrDeinit(&key);
            StrDeinit(&value);
            si = read_si;
        }
        lookup = StrInitFromCstr(key, ZstrLen(key), MapAllocator(cfg));
        value  = kvconfig_get_ptr_str(cfg, &lookup);
        StrDeinit(&lookup);
        return value;
    }
            if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
                LOG_ERROR("Failed to read string key in object. Invalid JSON");
                StrDeinit(&key);
                DefaultAllocatorDeinit(&scratch);
                return saved_si;
            if (!StrIterPeek(&si, &c) || c != ':') {
                LOG_ERROR("Expected ':' after key string. Failed to read JSON");
                StrDeinit(&key);
                DefaultAllocatorDeinit(&scratch);
                return saved_si;
            if (StrIterIndex(&read_si) == StrIterIndex(&si)) {
                LOG_ERROR("Failed to parse value. Invalid JSON.");
                StrDeinit(&key);
                DefaultAllocatorDeinit(&scratch);
                return saved_si;
            LOG_INFO("User skipped reading of '{}' field in JSON object.", key);
    
            StrDeinit(&key);
            si = read_si;
            si = JSkipWhitespace(si);
                    if (has_exp) {
                        LOG_ERROR("Invalid number. Multiple exponent indicators.");
                        StrDeinit(&ns);
                        DefaultAllocatorDeinit(&scratch);
                        return saved_si;
                    if (is_flt) {
                        LOG_ERROR("Invalid number. Multiple decimal indicators.");
                        StrDeinit(&ns);
                        DefaultAllocatorDeinit(&scratch);
                        return saved_si;
                            "must appear after exponent 'E' or 'e' indicator."
                        );
                        StrDeinit(&ns);
                        DefaultAllocatorDeinit(&scratch);
                        return saved_si;
                            "Expected only once after 'e' or 'E'."
                        );
                        StrDeinit(&ns);
                        DefaultAllocatorDeinit(&scratch);
                        return saved_si;
        if (!StrLen(&ns)) {
            LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
            StrDeinit(&ns);
            DefaultAllocatorDeinit(&scratch);
            return saved_si;
        if (end == StrBegin(&ns)) {
            LOG_ERROR("Failed to convert string to number.");
            StrDeinit(&ns);
            DefaultAllocatorDeinit(&scratch);
            return saved_si;
        num->is_float = is_flt;
    
        StrDeinit(&ns);
        DefaultAllocatorDeinit(&scratch);
        return si;
            Str              s       = StrInit(&scratch);
            si                       = JReadString(si, &s);
            StrDeinit(&s);
            DefaultAllocatorDeinit(&scratch);
            return;
        VecDeinit(&self->entries);
        StrDeinit(&self->string_pool);
        MemSet(self, 0, sizeof(*self));
    }
            VecDeinit(&self->entries);
        if (StrAllocator(&self->string_pool))
            StrDeinit(&self->string_pool);
        MemSet(self, 0, sizeof(*self));
    }
                AllocatorFree(alloc, self->stream_block_counts);
        }
        StrDeinit(&self->name_pool);
        VecDeinit(&self->functions);
        BufDeinit(&self->data);
            Str dummy = StrInit(alloc);
            if (!decode_name(&it, &dummy)) {
                StrDeinit(&dummy);
                return false;
            }
                return false;
            }
            StrDeinit(&dummy);
            u16 qtype, qclass;
            if (!BufReadFmt(&it, "{>2r}{>2r}", qtype, qclass)) {
            return;
        }
        StrDeinit(&self->name);
        StrDeinit(&self->target);
        VecDeinit(&self->rdata);
        }
        StrDeinit(&self->name);
        StrDeinit(&self->target);
        VecDeinit(&self->rdata);
    }
                }
                WriteFmtLn("{}", s);
                StrDeinit(&s);
            }
            }
            HttpRequestDeinit(&req);
            StrDeinit(&raw);
        }
    }
            LOG_ERROR("failed to dial upstream for client [{}]", peer_str);
            SocketClose(client);
            StrDeinit(&peer_str);
            return;
        }
            SocketClose(&upstream);
            SocketClose(client);
            StrDeinit(&peer_str);
            return;
        }
        SocketClose(&upstream);
        SocketClose(client);
        StrDeinit(&peer_str);
    }
                        Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
                        VecPushBack(&temp, str);
                        StrDeinit(&str);
                    }
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') {                                                 \
                    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    if (StrIterIndex(&UNPL(skip_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        StrDeinit(&key);                                                                                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                    si = UNPL(skip_si);                                                                                    \
                }                                                                                                          \
                StrDeinit(&key);                                                                                           \
                si                 = JSkipWhitespace(si);                                                                  \
                UNPL(expect_comma) = true;                                                                                 \
    
    void EdgeCaseDataDeinit(EdgeCaseData *data) {
        StrDeinit(&data->empty_string);
        VecDeinit(&data->empty_array);
        VecDeinit(&data->numbers);
        }
    
        StrDeinit(&json1);
        StrDeinit(&json2);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&json1);
        StrDeinit(&json2);
        DefaultAllocatorDeinit(&alloc);
        return success;
        StrIter si2   = StrIterFromStr(json2);
    
        Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        JR_OBJ(si2, {
        }
    
        StrDeinit(&json1);
        StrDeinit(&json2);
        VecDeinit(&items);
    
        StrDeinit(&json1);
        StrDeinit(&json2);
        VecDeinit(&items);
        VecDeinit(&data);
        }
    
        StrDeinit(&json);
        StrDeinit(&obj.name);
        StrDeinit(&obj.description);
    
        StrDeinit(&json);
        StrDeinit(&obj.name);
        StrDeinit(&obj.description);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&obj.name);
        StrDeinit(&obj.description);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&obj.path);
        StrDeinit(&obj.message);
    
        StrDeinit(&json);
        StrDeinit(&obj.path);
        StrDeinit(&obj.message);
        StrDeinit(&obj.data);
        StrDeinit(&json);
        StrDeinit(&obj.path);
        StrDeinit(&obj.message);
        StrDeinit(&obj.data);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&obj.path);
        StrDeinit(&obj.message);
        StrDeinit(&obj.data);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&obj.escaped);
        StrDeinit(&obj.backslash);
    
        StrDeinit(&json);
        StrDeinit(&obj.escaped);
        StrDeinit(&obj.backslash);
        StrDeinit(&obj.newline);
        StrDeinit(&json);
        StrDeinit(&obj.escaped);
        StrDeinit(&obj.backslash);
        StrDeinit(&obj.newline);
        StrDeinit(&obj.tab);
        StrDeinit(&obj.escaped);
        StrDeinit(&obj.backslash);
        StrDeinit(&obj.newline);
        StrDeinit(&obj.tab);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&obj.backslash);
        StrDeinit(&obj.newline);
        StrDeinit(&obj.tab);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&obj.name);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&json);
        StrDeinit(&obj.name);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        VecDeinit(&obj.filled_items);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
    // Cleanup functions
    void AnnSymbolDeinit(AnnSymbol *sym) {
        StrDeinit(&sym->analysis_name);
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
    void AnnSymbolDeinit(AnnSymbol *sym) {
        StrDeinit(&sym->analysis_name);
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
        StrDeinit(&sym->function_mangled_name);
        StrDeinit(&sym->analysis_name);
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
        StrDeinit(&sym->function_mangled_name);
    }
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
        StrDeinit(&sym->function_mangled_name);
    }
    
    void FunctionInfoDeinit(FunctionInfo *info) {
        StrDeinit(&info->name);
    }
    
    void SearchResultDeinit(SearchResult *result) {
        StrDeinit(&result->binary_name);
        StrDeinit(&result->sha256);
        VecDeinit(&result->tags);
    void SearchResultDeinit(SearchResult *result) {
        StrDeinit(&result->binary_name);
        StrDeinit(&result->sha256);
        VecDeinit(&result->tags);
        StrDeinit(&result->created_at);
        StrDeinit(&result->sha256);
        VecDeinit(&result->tags);
        StrDeinit(&result->created_at);
        StrDeinit(&result->model_name);
        StrDeinit(&result->owned_by);
        VecDeinit(&result->tags);
        StrDeinit(&result->created_at);
        StrDeinit(&result->model_name);
        StrDeinit(&result->owned_by);
    }
        StrDeinit(&result->created_at);
        StrDeinit(&result->model_name);
        StrDeinit(&result->owned_by);
    }
        }
    
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
    
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
        return result;
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
        return result;
    }
        }
    
        StrDeinit(&json);
        StrDeinit(&data.user.profile.name);
        StrDeinit(&data.status);
    
        StrDeinit(&json);
        StrDeinit(&data.user.profile.name);
        StrDeinit(&data.status);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&data.user.profile.name);
        StrDeinit(&data.status);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&data.company.departments.engineering.head);
        StrDeinit(&data.company.name);
    
        StrDeinit(&json);
        StrDeinit(&data.company.departments.engineering.head);
        StrDeinit(&data.company.name);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&data.company.departments.engineering.head);
        StrDeinit(&data.company.name);
        DefaultAllocatorDeinit(&alloc);
        return success;
                        });
    
                        StrDeinit(&target_key);
                    }
                });
                });
    
                StrDeinit(&source_key);
            });
        });
        }
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        VecDeinit(&functions);
        DefaultAllocatorDeinit(&alloc);
        result.analysis_id  = 999;
        result.sha256       = StrInitFromZstr("abc123", &alloc);
        result.tags         = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
        }
    
        StrDeinit(&json);
        SearchResultDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
                });
    
                StrDeinit(&target_key);
                    });
                    });
    
                    StrDeinit(&source_key);
                }
    });
    }
    
    StrDeinit(&json);
    VecDeinit(&symbols);
    return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&deep_message);
        StrDeinit(&test_name);
    
        StrDeinit(&json);
        StrDeinit(&deep_message);
        StrDeinit(&test_name);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&deep_message);
        StrDeinit(&test_name);
        DefaultAllocatorDeinit(&alloc);
        return success;
        VecPushBack(&numbers, num3);
    
        Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
        }
    
        StrDeinit(&json);
        VecDeinit(&numbers);
        VecDeinit(&strings);
    // Cleanup functions
    void PersonDeinit(Person *person) {
        StrDeinit(&person->name);
    }
    
    void ConfigDeinit(Config *config) {
        StrDeinit(&config->log_level);
    }
    
    void SimpleProductDeinit(SimpleProduct *product) {
        StrDeinit(&product->name);
        VecDeinit(&product->tags);
    }
        }
    
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
    
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
        return result;
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
        return result;
    }
        }
    
        StrDeinit(&json);
        StrDeinit(&name);
        StrDeinit(&city);
    
        StrDeinit(&json);
        StrDeinit(&name);
        StrDeinit(&city);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&name);
        StrDeinit(&city);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        PersonDeinit(&person);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        ConfigDeinit(&config);
        DefaultAllocatorDeinit(&alloc);
        Str  json    = StrInit(&alloc);
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
        }
    
        StrDeinit(&json);
        VecDeinit(&languages);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        StrDeinit(&data.user.name);
        StrDeinit(&data.user.email);
    
        StrDeinit(&json);
        StrDeinit(&data.user.name);
        StrDeinit(&data.user.email);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&data.user.name);
        StrDeinit(&data.user.email);
        DefaultAllocatorDeinit(&alloc);
        return success;
        product.name          = StrInitFromZstr("Laptop", &alloc);
        product.price         = 999.99;
        product.tags          = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
        }
    
        StrDeinit(&json);
        SimpleProductDeinit(&product);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
    
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
        return result;
        StrDeinit(&expected_str);
        StrDeinit(&output_clean);
        StrDeinit(&expected_clean);
        return result;
    }
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
    
        Vec(i32) empty_numbers = VecInit(&alloc);
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        JW_OBJ(json, {
        }
    
        StrDeinit(&json);
        VecDeinit(&empty_numbers);
        VecDeinit(&empty_strings);
        }
    
        StrDeinit(&json);
        StrDeinit(&empty_name);
        StrDeinit(&empty_desc);
    
        StrDeinit(&json);
        StrDeinit(&empty_name);
        StrDeinit(&empty_desc);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&empty_name);
        StrDeinit(&empty_desc);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        WriteFmtLn("[DEBUG] Large numbers JSON: {}", json);
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&path);
        StrDeinit(&message);
    
        StrDeinit(&json);
        StrDeinit(&path);
        StrDeinit(&message);
        StrDeinit(&data);
        StrDeinit(&json);
        StrDeinit(&path);
        StrDeinit(&message);
        StrDeinit(&data);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&path);
        StrDeinit(&message);
        StrDeinit(&data);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&quotes);
        StrDeinit(&backslash);
    
        StrDeinit(&json);
        StrDeinit(&quotes);
        StrDeinit(&backslash);
        StrDeinit(&newline);
        StrDeinit(&json);
        StrDeinit(&quotes);
        StrDeinit(&backslash);
        StrDeinit(&newline);
        StrDeinit(&tab);
        StrDeinit(&quotes);
        StrDeinit(&backslash);
        StrDeinit(&newline);
        StrDeinit(&tab);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&backslash);
        StrDeinit(&newline);
        StrDeinit(&tab);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        VecDeinit(&empty_list);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        VecDeinit(&empty_arr);
        VecDeinit(&filled_arr);
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
            success = false;
    
        StrDeinit(&json1);
        StrDeinit(&json2);
        StrDeinit(&json3);
    
        StrDeinit(&json1);
        StrDeinit(&json2);
        StrDeinit(&json3);
        StrDeinit(&json4);
        StrDeinit(&json1);
        StrDeinit(&json2);
        StrDeinit(&json3);
        StrDeinit(&json4);
        StrDeinit(&single_str);
        StrDeinit(&json2);
        StrDeinit(&json3);
        StrDeinit(&json4);
        StrDeinit(&single_str);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json3);
        StrDeinit(&json4);
        StrDeinit(&single_str);
        DefaultAllocatorDeinit(&alloc);
        return success;
    
    void AnnSymbolDeinit(AnnSymbol *sym) {
        StrDeinit(&sym->analysis_name);
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
    void AnnSymbolDeinit(AnnSymbol *sym) {
        StrDeinit(&sym->analysis_name);
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
        StrDeinit(&sym->function_mangled_name);
        StrDeinit(&sym->analysis_name);
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
        StrDeinit(&sym->function_mangled_name);
    }
        StrDeinit(&sym->function_name);
        StrDeinit(&sym->sha256);
        StrDeinit(&sym->function_mangled_name);
    }
    
    void FunctionInfoDeinit(FunctionInfo *info) {
        StrDeinit(&info->name);
    }
    
    void ModelInfoDeinit(ModelInfo *info) {
        StrDeinit(&info->name);
    }
    
    void SearchResultDeinit(SearchResult *result) {
        StrDeinit(&result->binary_name);
        StrDeinit(&result->sha256);
        VecForeach(&result->tags, tag) {
    void SearchResultDeinit(SearchResult *result) {
        StrDeinit(&result->binary_name);
        StrDeinit(&result->sha256);
        VecForeach(&result->tags, tag) {
            StrDeinit(&tag);
        StrDeinit(&result->sha256);
        VecForeach(&result->tags, tag) {
            StrDeinit(&tag);
        }
        VecDeinit(&result->tags);
        }
        VecDeinit(&result->tags);
        StrDeinit(&result->created_at);
        StrDeinit(&result->model_name);
        StrDeinit(&result->owned_by);
        VecDeinit(&result->tags);
        StrDeinit(&result->created_at);
        StrDeinit(&result->model_name);
        StrDeinit(&result->owned_by);
    }
        StrDeinit(&result->created_at);
        StrDeinit(&result->model_name);
        StrDeinit(&result->owned_by);
    }
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&data.name);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&json);
        StrDeinit(&data.name);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&data.user.profile.name);
        StrDeinit(&data.status);
    
        StrDeinit(&json);
        StrDeinit(&data.user.profile.name);
        StrDeinit(&data.status);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&data.user.profile.name);
        StrDeinit(&data.status);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&data.company.departments.engineering.head);
        StrDeinit(&data.company.name);
    
        StrDeinit(&json);
        StrDeinit(&data.company.departments.engineering.head);
        StrDeinit(&data.company.name);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&data.company.departments.engineering.head);
        StrDeinit(&data.company.name);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        VecDeinit(&symbols);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        StrDeinit(&info.name);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&json);
        StrDeinit(&info.name);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        StrDeinit(&info.name);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&json);
        StrDeinit(&info.name);
        DefaultAllocatorDeinit(&alloc);
        return success;
        result.binary_name  = StrInit(&alloc);
        result.sha256       = StrInit(&alloc);
        result.tags         = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit, &alloc);
        result.created_at   = StrInit(&alloc);
        result.model_name   = StrInit(&alloc);
        }
    
        StrDeinit(&json);
        SearchResultDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
    
        StrDeinit(&json);
        StrDeinit(&response.message);
        VecDeinit(&response.data);
        DefaultAllocatorDeinit(&alloc);
    // Cleanup functions
    void PersonDeinit(Person *person) {
        StrDeinit(&person->name);
    }
    
    void ConfigDeinit(Config *config) {
        StrDeinit(&config->log_level);
    }
    
    void SimpleProductDeinit(SimpleProduct *product) {
        StrDeinit(&product->name);
        VecDeinit(&product->tags);
    }
        }
    
        StrDeinit(&json);
        StrDeinit(&name);
        StrDeinit(&city);
    
        StrDeinit(&json);
        StrDeinit(&name);
        StrDeinit(&city);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&name);
        StrDeinit(&city);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        PersonDeinit(&person);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        ConfigDeinit(&config);
        DefaultAllocatorDeinit(&alloc);
        StrIter si      = StrIterFromStr(json);
    
        Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        JR_OBJ(si, {
        }
    
        StrDeinit(&json);
        VecDeinit(&languages);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&json);
        StrDeinit(&data.user.name);
        StrDeinit(&data.user.email);
    
        StrDeinit(&json);
        StrDeinit(&data.user.name);
        StrDeinit(&data.user.email);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&data.user.name);
        StrDeinit(&data.user.email);
        DefaultAllocatorDeinit(&alloc);
        return success;
        SimpleProduct product = {0};
        product.name          = StrInit(&alloc);
        product.tags          = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit, &alloc);
    
        JR_OBJ(si, {
        }
    
        StrDeinit(&json);
        SimpleProductDeinit(&product);
        DefaultAllocatorDeinit(&alloc);
    // Cleanup functions
    void TestPersonDeinit(TestPerson *person) {
        StrDeinit(&person->name);
    }
    
    void TestConfigDeinit(TestConfig *config) {
        StrDeinit(&config->log_level);
        VecDeinit(&config->features);
    }
        }
    
        StrDeinit(&json);
        StrDeinit(&original.message);
        StrDeinit(&parsed.message);
    
        StrDeinit(&json);
        StrDeinit(&original.message);
        StrDeinit(&parsed.message);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&json);
        StrDeinit(&original.message);
        StrDeinit(&parsed.message);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
    
        // Cleanup
        StrDeinit(&json);
        StrDeinit(&original.empty);
        StrDeinit(&original.simple);
        // Cleanup
        StrDeinit(&json);
        StrDeinit(&original.empty);
        StrDeinit(&original.simple);
        StrDeinit(&original.with_spaces);
        StrDeinit(&json);
        StrDeinit(&original.empty);
        StrDeinit(&original.simple);
        StrDeinit(&original.with_spaces);
        StrDeinit(&original.with_special);
        StrDeinit(&original.empty);
        StrDeinit(&original.simple);
        StrDeinit(&original.with_spaces);
        StrDeinit(&original.with_special);
        StrDeinit(&parsed.empty);
        StrDeinit(&original.simple);
        StrDeinit(&original.with_spaces);
        StrDeinit(&original.with_special);
        StrDeinit(&parsed.empty);
        StrDeinit(&parsed.simple);
        StrDeinit(&original.with_spaces);
        StrDeinit(&original.with_special);
        StrDeinit(&parsed.empty);
        StrDeinit(&parsed.simple);
        StrDeinit(&parsed.with_spaces);
        StrDeinit(&original.with_special);
        StrDeinit(&parsed.empty);
        StrDeinit(&parsed.simple);
        StrDeinit(&parsed.with_spaces);
        StrDeinit(&parsed.with_special);
        StrDeinit(&parsed.empty);
        StrDeinit(&parsed.simple);
        StrDeinit(&parsed.with_spaces);
        StrDeinit(&parsed.with_special);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&parsed.simple);
        StrDeinit(&parsed.with_spaces);
        StrDeinit(&parsed.with_special);
        DefaultAllocatorDeinit(&alloc);
        return success;
        // Original data
        Vec(i32) original_numbers = VecInit(&alloc);
        Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Populate arrays
        // Read back from JSON
        Vec(i32) parsed_numbers = VecInit(&alloc);
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        StrIter si = StrIterFromStr(json);
    
        // Cleanup
        StrDeinit(&json);
        VecDeinit(&original_numbers);
        VecDeinit(&original_strings);
    
        // Cleanup
        StrDeinit(&json);
        TestPersonDeinit(&original_person);
        TestPersonDeinit(&parsed_person);
        original.config.timeout    = 30;
        original.config.log_level  = StrInitFromZstr("INFO", &alloc);
        original.config.features   = VecInitWithDeepCopyT(original.config.features, NULL, StrDeinit, &alloc);
    
        // Create strings and push them properly
        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);
        parsed.flags             = VecInitT(parsed.flags, &alloc);
    
        // Cleanup
        StrDeinit(&json);
        ComplexDataDeinit(&original);
        ComplexDataDeinit(&parsed);
        // Original empty data
        Vec(i32) empty_numbers = VecInit(&alloc);
        Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str empty_str          = StrInit(&alloc);
        // Read back from JSON
        Vec(i32) parsed_numbers = VecInit(&alloc);
        Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
        Str  parsed_str         = StrInit(&alloc);
        bool found_empty_object = false;
    
        // Cleanup
        StrDeinit(&json);
        StrDeinit(&empty_str);
        StrDeinit(&parsed_str);
        // Cleanup
        StrDeinit(&json);
        StrDeinit(&empty_str);
        StrDeinit(&parsed_str);
        VecDeinit(&empty_numbers);
        StrDeinit(&json);
        StrDeinit(&empty_str);
        StrDeinit(&parsed_str);
        VecDeinit(&empty_numbers);
        VecDeinit(&empty_strings);
        }
    
        StrDeinit(&json);
        DefaultAllocatorDeinit(&alloc);
        return success;
        result = result && KvConfigGetBool(&cfg, "debug", &debug) && debug;
    
        StrDeinit(&src);
        MapDeinit(&cfg);
        DefaultAllocatorDeinit(&alloc);
        result = result && empty && (StrLen(empty) == 0);
    
        StrDeinit(&src);
        MapDeinit(&cfg);
        DefaultAllocatorDeinit(&alloc);
        result = result && (StrCmp(stored_host, "localhost") == 0);
    
        StrDeinit(&host_copy);
        StrDeinit(&src);
        MapDeinit(&cfg);
    
        StrDeinit(&host_copy);
        StrDeinit(&src);
        MapDeinit(&cfg);
        DefaultAllocatorDeinit(&alloc);
        result = result && !KvConfigGetF64(&cfg, "missing", &pi);
    
        StrDeinit(&src);
        MapDeinit(&cfg);
        DefaultAllocatorDeinit(&alloc);
        result = result && !KvConfigContains(&cfg, "later");
    
        StrDeinit(&src);
        MapDeinit(&cfg);
        DefaultAllocatorDeinit(&alloc);
        result = result && (ZstrCompare(StrBegin(&s), "Hel") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "llo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "Hlo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "Hell") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "Hel") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "Hlo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "Heo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        StrAppendFmt(&body, "<h1>hi</h1>");
        HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);
        StrDeinit(&body);
    
        Str wire = HttpResponseSerialize(&response, alloc_base);
                  ZstrFindSubstring(StrBegin(&wire), "\r\n\r\n<h1>hi</h1>") != NULL;
    
        StrDeinit(&wire);
        HttpResponseDeinit(&response);
        DefaultAllocatorDeinit(&alloc);
        result = result && (StrCapacity(&s) < 100) && (StrCapacity(&s) >= StrLen(&s));
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrBegin(&s)[1] == 'l' && StrBegin(&s)[2] == 'e');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrLen(&s) == 8) && (ZstrCompareN(StrBegin(&s), "Hel", 3) == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrCapacity(&s) >= 100);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrBegin(&s) != NULL);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Test with an even-length string
        StrDeinit(&s);
        s = StrInitFromZstr("abcd", &alloc);
    
        // Test with a single-character string
        StrDeinit(&s);
        s = StrInitFromZstr("a", &alloc);
    
        // Test with an empty string
        StrDeinit(&s);
        s = StrInit(&alloc);
        result = result && (StrLen(&s) == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result   = result && (cmp5 != 0);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        StrDeinit(&s3);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        StrDeinit(&s3);
        StrDeinit(&s4);
        StrDeinit(&s1);
        StrDeinit(&s2);
        StrDeinit(&s3);
        StrDeinit(&s4);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&s2);
        StrDeinit(&s3);
        StrDeinit(&s4);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (found5 != NULL && ZstrCompareN(found5, "World", 3) == 0);
    
        StrDeinit(&haystack);
        StrDeinit(&needle1);
        StrDeinit(&needle2);
    
        StrDeinit(&haystack);
        StrDeinit(&needle1);
        StrDeinit(&needle2);
        StrDeinit(&needle3);
        StrDeinit(&haystack);
        StrDeinit(&needle1);
        StrDeinit(&needle2);
        StrDeinit(&needle3);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&needle1);
        StrDeinit(&needle2);
        StrDeinit(&needle3);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (StrIndexOf(&haystack, "") == 0);
    
        StrDeinit(&haystack);
        StrDeinit(&needle);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&haystack);
        StrDeinit(&needle);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && !StrEndsWith(&s, "ello", 4);
    
        StrDeinit(&s);
        StrDeinit(&prefix);
        StrDeinit(&suffix);
    
        StrDeinit(&s);
        StrDeinit(&prefix);
        StrDeinit(&suffix);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&s);
        StrDeinit(&prefix);
        StrDeinit(&suffix);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Test multiple replacements
        StrDeinit(&s1);
        s1 = StrInitFromZstr("Hello Hello Hello", &alloc);
        StrReplace(&s1, "Hello", "Hi", 2);
    
        // Test Cstr-form (fixed-length views) - use the full "World" string instead of just "Wo"
        StrDeinit(&s1);
        s1 = StrInitFromZstr("Hello World", &alloc);
        StrReplace(&s1, "World", 5, "Universe", 8, 1);
    
        // Test Str-form
        StrDeinit(&s1);
        s1          = StrInitFromZstr("Hello World", &alloc);
        Str find    = StrInitFromZstr("World", &alloc);
        result = result && (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);
    
        StrDeinit(&s1);
        StrDeinit(&find);
        StrDeinit(&replace);
    
        StrDeinit(&s1);
        StrDeinit(&find);
        StrDeinit(&replace);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&s1);
        StrDeinit(&find);
        StrDeinit(&replace);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        VecDeinit(&iters);
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        Str  stripped = StrLStrip(&s1, NULL);
        bool result   = (ZstrCompare(StrBegin(&stripped), "Hello  ") == 0);
        StrDeinit(&stripped);
    
        // Test StrRStrip
        stripped = StrRStrip(&s1, NULL);
        result   = result && (ZstrCompare(StrBegin(&stripped), "  Hello") == 0);
        StrDeinit(&stripped);
    
        // Test StrStrip
        stripped = StrStrip(&s1, NULL);
        result   = result && (ZstrCompare(StrBegin(&stripped), "Hello") == 0);
        StrDeinit(&stripped);
    
        // Test with custom strip characters
    
        // Test with custom strip characters
        StrDeinit(&s1);
        s1 = StrInitFromZstr("***Hello***", &alloc);
        stripped = StrLStrip(&s1, "*");
        result   = result && (ZstrCompare(StrBegin(&stripped), "Hello***") == 0);
        StrDeinit(&stripped);
    
        stripped = StrRStrip(&s1, "*");
        stripped = StrRStrip(&s1, "*");
        result   = result && (ZstrCompare(StrBegin(&stripped), "***Hello") == 0);
        StrDeinit(&stripped);
    
        stripped = StrStrip(&s1, "*");
        stripped = StrStrip(&s1, "*");
        result   = result && (ZstrCompare(StrBegin(&stripped), "Hello") == 0);
        StrDeinit(&stripped);
    
        StrDeinit(&s1);
        StrDeinit(&stripped);
    
        StrDeinit(&s1);
        DefaultAllocatorDeinit(&alloc);
        return result;
        ok              = ok && StrCmpIgnoreCase(&non_ascii_a, &non_ascii_b) == 0;
    
        StrDeinit(&hello_lc);
        StrDeinit(&hello_uc);
        StrDeinit(&hello_mc);
    
        StrDeinit(&hello_lc);
        StrDeinit(&hello_uc);
        StrDeinit(&hello_mc);
        StrDeinit(&world);
        StrDeinit(&hello_lc);
        StrDeinit(&hello_uc);
        StrDeinit(&hello_mc);
        StrDeinit(&world);
        StrDeinit(&hello_x);
        StrDeinit(&hello_uc);
        StrDeinit(&hello_mc);
        StrDeinit(&world);
        StrDeinit(&hello_x);
        StrDeinit(&non_ascii_a);
        StrDeinit(&hello_mc);
        StrDeinit(&world);
        StrDeinit(&hello_x);
        StrDeinit(&non_ascii_a);
        StrDeinit(&non_ascii_b);
        StrDeinit(&world);
        StrDeinit(&hello_x);
        StrDeinit(&non_ascii_a);
        StrDeinit(&non_ascii_b);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&hello_x);
        StrDeinit(&non_ascii_a);
        StrDeinit(&non_ascii_b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        result      = result && (ZstrCompare(StrBegin(&text), "1101") == 0);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        result      = result && (ZstrCompare(StrBegin(&text), "cdef1234") == 0);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        result      = result && (ZstrCompare(StrBegin(&text), "12345678") == 0);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        result      = result && (ZstrCompare(StrBegin(&text), "1011") == 0);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = ZstrCompare(StrBegin(&text), digits) == 0;
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        result      = result && (ZstrCompare(StrBegin(&text), "zz") == 0);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = ZstrCompare(StrBegin(&text), "BEEF") == 0;
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
                      (StrAllocator(&text)->retry_limit == alloc.base.retry_limit);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        result      = result && (ZstrCompare(StrBegin(&text), "0") == 0);
    
        StrDeinit(&text);
        IntDeinit(&zero);
        DefaultAllocatorDeinit(&alloc);
        result      = result && (ZstrCompare(StrBegin(&text), "755") == 0);
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = ZstrCompare(StrBegin(&text), hex) == 0;
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = StrLen(&text) == 0;
    
        StrDeinit(&text);
        IntDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
    #endif
    
        StrDeinit(&rendered);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && ZstrFindSubstring(StrBegin(&rendered), "bt_vec_capture_outer") != NULL;
    
        StrDeinit(&rendered);
        VecDeinit(&frames);
        DefaultAllocatorDeinit(&alloc);
        bool ok = StrLen(&out) > 0 && ZstrFindSubstring(StrBegin(&out), "bt_capture_with_helper") != NULL;
    
        StrDeinit(&out);
        SymbolResolverDeinit(&res);
        DefaultAllocatorDeinit(&alloc);
        ok      = ok && ZstrFindSubstring(StrBegin(&rendered), "cfi_capture_outer") != NULL;
    
        StrDeinit(&rendered);
        SymbolResolverDeinit(&res);
        DefaultAllocatorDeinit(&alloc);
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (ZstrCompare(StrBegin(&s), "nan") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Test hexadecimal conversion with explicit base
        StrDeinit(&s);
        s                     = StrInitFromZstr("ABCD", &alloc); // No 0x prefix when base is explicitly 16
        StrParseConfig config = {.base = 16};
    
        // Test hexadecimal conversion (auto-detect base with 0)
        StrDeinit(&s);
        s       = StrInitFromZstr("0xABCD", &alloc);
        success = StrToU64(&s, &value, NULL);
    
        // Test binary conversion
        StrDeinit(&s);
        s       = StrInitFromZstr("0b101010", &alloc);
        success = StrToU64(&s, &value, NULL);
    
        // Test octal conversion
        StrDeinit(&s);
        s       = StrInitFromZstr("0o52", &alloc);
        success = StrToU64(&s, &value, NULL);
    
        // Test zero
        StrDeinit(&s);
        s       = StrInitFromZstr("0", &alloc);
        success = StrToU64(&s, &value, NULL);
    
        // Test invalid input
        StrDeinit(&s);
        s       = StrInitFromZstr("not a number", &alloc);
        success = StrToU64(&s, &value, NULL);
    
        // Test negative number (should fail for unsigned)
        StrDeinit(&s);
        s       = StrInitFromZstr("-123", &alloc);
        success = StrToU64(&s, &value, NULL);
        result  = result && (!success);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Test negative decimal conversion
        StrDeinit(&s);
        s       = StrInitFromZstr("-12345", &alloc);
        success = StrToI64(&s, &value, NULL);
    
        // Test hexadecimal conversion
        StrDeinit(&s);
        s       = StrInitFromZstr("0xABCD", &alloc);
        success = StrToI64(&s, &value, NULL);
    
        // Test binary conversion
        StrDeinit(&s);
        s       = StrInitFromZstr("0b101010", &alloc);
        success = StrToI64(&s, &value, NULL);
    
        // Test zero
        StrDeinit(&s);
        s       = StrInitFromZstr("0", &alloc);
        success = StrToI64(&s, &value, NULL);
    
        // Test invalid input
        StrDeinit(&s);
        s       = StrInitFromZstr("not a number", &alloc);
        success = StrToI64(&s, &value, NULL);
        result  = result && (!success);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Test fractional conversion
        StrDeinit(&s);
        s       = StrInitFromZstr("123.456", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test negative number
        StrDeinit(&s);
        s       = StrInitFromZstr("-123.456", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test scientific notation
        StrDeinit(&s);
        s       = StrInitFromZstr("1.23e2", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test zero
        StrDeinit(&s);
        s       = StrInitFromZstr("0", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test infinity
        StrDeinit(&s);
        s       = StrInitFromZstr("inf", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test negative infinity
        StrDeinit(&s);
        s       = StrInitFromZstr("-inf", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test NaN
        StrDeinit(&s);
        s       = StrInitFromZstr("nan", &alloc);
        success = StrToF64(&s, &value, NULL);
    
        // Test invalid input
        StrDeinit(&s);
        s       = StrInitFromZstr("not a number", &alloc);
        success = StrToF64(&s, &value, NULL);
        result  = result && (!success);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
            result        = result && success && (recovered_u64 == u64_values[i]);
    
            StrDeinit(&s);
        }
            result             = result && success && (recovered_i64 == i64_values[i]);
    
            StrDeinit(&s);
        }
                result        = result && success && (F64Abs(recovered_f64 - f64_values[i]) < tolerance);
    
                StrDeinit(&s);
            }
        }
            result                      = result && success && (recovered == base);
    
            StrDeinit(&s);
        }
        result              = result && success && (recovered_large > 1e299);
    
        StrDeinit(&s);
    
        // Test prefix handling
            bool           success  = StrToU64(&test_str, &value, prefix_tests[i].base == 0 ? NULL : &config);
            result                  = result && success && (value == prefix_tests[i].expected);
            StrDeinit(&test_str);
        }
            }
    
            StrDeinit(&s);
        }
            result     = result && has_E;
    
            StrDeinit(&s);
        }
            result                   = result && success && (recovered == large_value);
    
            StrDeinit(&s);
        }
            result = result && success && (recovered == test_value);
    
            StrDeinit(&s);
        }
            result = result && success && (recovered == test_value);
    
            StrDeinit(&s);
        }
                result = result && success && (recovered == test_values[i]);
    
                StrDeinit(&s);
    
                if (!result)
            result         = result && success && (recovered == test_value);
    
            StrDeinit(&s);
    
            if (!result)
                result = result && success && (F64Abs(recovered - test_value) < tolerance);
    
                StrDeinit(&s);
    
                if (!result)
        result = result && (success || !success); // Either succeeds or fails gracefully
    
        StrDeinit(&long_str);
    
        DefaultAllocatorDeinit(&alloc);
        result = result && StrEmpty(&s);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (first == 'H');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (last == 'o');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (*begin == 'H');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (*end == '\0');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (c0 == 'H' && c1 == 'e' && c2 == 'l' && c3 == 'l' && c4 == 'o');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (*p0 == 'H' && *p1 == 'e' && *p2 == 'l' && *p3 == 'l' && *p4 == 'o');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        SocketAddr connect_addr;
        bool       parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);
        StrDeinit(&local_str);
        if (!parsed) {
            ListenerClose(&listener);
            Str rendered = SocketAddrFormat(&addr, alloc_base);
            ok           = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "127.0.0.1:8080") == 0;
            StrDeinit(&rendered);
        }
            Str rendered = SocketAddrFormat(&addr, alloc_base);
            ok           = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "[::1]:8080") == 0;
            StrDeinit(&rendered);
        }
        ok         = ok && (ZstrCompare(StrBegin(&out), "(3, 4)") == 0);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok            = ok && (ZstrCompare(StrBegin(&out), "got 7 hits at (-1, 2)") == 0);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && (dst.x == src.x) && (dst.y == src.y);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok      = ok && (ZstrCompare(StrBegin(&out), "[(0, 0)..(10, 20)]") == 0);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && (dst.max.x == src.max.x) && (dst.max.y == src.max.y);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok      = ok && (ZstrCompare(StrBegin(&out), "42:[(0, 0)..(100, 50)]@(50, 25)") == 0);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && (dst.centroid.x == src.centroid.x) && (dst.centroid.y == src.centroid.y);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok      = ok && (ZstrCompare(StrBegin(&out), "score=1.5 region=7:[(1, 2)..(3, 4)]@(2, 3) origin=(0, 0)") == 0);
    
        StrDeinit(&out);
        DefaultAllocatorDeinit(&alloc);
        return ok;
            Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
            ok    = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "203.0.113.7:9999") == 0;
            StrDeinit(&s);
        }
            // SocketAddrFormat emits the bracketed form for IPv6.
            ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "[::1]:443") == 0;
            StrDeinit(&s);
        }
                    ok = false;
                }
                StrDeinit(&s);
            }
        }
            Str s = SocketAddrFormat(&one, a);
            ok    = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "127.0.0.1:80") == 0;
            StrDeinit(&s);
        }
        ok      = ok && (ZstrFindSubstring(StrBegin(&out), "40 bytes") != NULL);
    
        StrDeinit(&out);
        HeapAllocatorDeinit(&scratch);
        if (p1)
        Str expected = StrInitFromZstr("Hello", &alloc);
        success      = success && (StrCmp(&s, &expected) == 0);
        StrDeinit(&expected);
        StrClear(&s);
        expected = StrInitFromZstr("Hello, World!", &alloc);
        success  = success && (StrCmp(&s, &expected) == 0);
        StrDeinit(&expected);
    
        {
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        Str expected = StrInitFromZstr("Alice", &alloc);
        success      = success && (StrCmp(&name, &expected) == 0);
        StrDeinit(&expected);
        StrClear(&name);
        expected = StrInitFromZstr("Bob", &alloc);
        success  = success && (StrCmp(&name, &expected) == 0);
        StrDeinit(&expected);
    
        StrDeinit(&name);
        StrDeinit(&expected);
    
        StrDeinit(&name);
        DefaultAllocatorDeinit(&alloc);
        WriteFmt("str_val test: comparing with 'Hello', pass = {}\n", str_pass ? "true" : "false");
        success = success && str_pass;
        StrDeinit(&expected);
        StrDeinit(&str_val);
        success = success && str_pass;
        StrDeinit(&expected);
        StrDeinit(&str_val);
    
        str_val = StrInit(&alloc);
        WriteFmt("quoted str_val test: comparing with 'World', pass = {}\n", quoted_str_pass ? "true" : "false");
        success = success && quoted_str_pass;
        StrDeinit(&expected);
        StrDeinit(&str_val);
        success = success && quoted_str_pass;
        StrDeinit(&expected);
        StrDeinit(&str_val);
    
        WriteFmt("Overall success: {}\n", success ? "true" : "false");
            success = success && test1_pass;
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
            success = success && test1_pass;
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
            success = success && test2_pass;
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
            success = success && test2_pass;
    
            StrDeinit(&result1);
            StrDeinit(&result2);
        }
    
            StrDeinit(&result1);
            StrDeinit(&result2);
        }
            success = success && test2_pass;
    
            StrDeinit(&result1);
            StrDeinit(&result2);
        }
    
            StrDeinit(&result1);
            StrDeinit(&result2);
        }
            success = success && test3_pass;
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
            success = success && test4_pass;
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
            success = success && test5_pass;
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
    
            StrDeinit(&expected);
            StrDeinit(&result);
        }
            (ZstrCompare(StrBegin(&result1), "10110") == 0) ? "true" : "false"
        );
        StrDeinit(&result1);
        BitVecDeinit(&bv1);
            (ZstrCompare(StrBegin(&result4), "1101") == 0) ? "true" : "false"
        );
        StrDeinit(&result4);
        BitVecDeinit(&bv4);
            (ZstrCompare(StrBegin(&result5), "0") == 0) ? "true" : "false"
        );
        StrDeinit(&result5);
        BitVecDeinit(&bv5);
        success  = success && (ZstrCompare(StrBegin(&oct_text), "755") == 0);
    
        StrDeinit(&dec_text);
        StrDeinit(&hex_text);
        StrDeinit(&bin_text);
    
        StrDeinit(&dec_text);
        StrDeinit(&hex_text);
        StrDeinit(&bin_text);
        StrDeinit(&oct_text);
        StrDeinit(&dec_text);
        StrDeinit(&hex_text);
        StrDeinit(&bin_text);
        StrDeinit(&oct_text);
        IntDeinit(&dec);
        StrDeinit(&hex_text);
        StrDeinit(&bin_text);
        StrDeinit(&oct_text);
        IntDeinit(&dec);
        IntDeinit(&hex);
        success  = success && (ZstrCompare(StrBegin(&neg_text), "-0.00125") == 0);
    
        StrDeinit(&dec_text);
        StrDeinit(&sci_text);
        StrDeinit(&neg_text);
    
        StrDeinit(&dec_text);
        StrDeinit(&sci_text);
        StrDeinit(&neg_text);
        FloatDeinit(&dec);
        StrDeinit(&dec_text);
        StrDeinit(&sci_text);
        StrDeinit(&neg_text);
        FloatDeinit(&dec);
        FloatDeinit(&sci);
                      ZstrCompare(StrBegin(stored_name), "alpha") == 0 && StrBegin(stored_name) != StrBegin(&name);
    
        StrDeinit(&name);
        GraphDeinit(&graph);
        DefaultAllocatorDeinit(&alloc);
        result      = result && !FloatEQ(&clone, &original);
    
        StrDeinit(&text);
        FloatDeinit(&original);
        FloatDeinit(&clone);
        result      = result && !FloatIsNegative(&value);
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        result      = result && FloatIsNegative(&value);
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
    
        IntDeinit(&integer);
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        FloatDeinit(&value);
        IntDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = ZstrCompare(StrBegin(&text), "-123.45") == 0;
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
                      (StrAllocator(&text)->retry_limit == alloc.base.retry_limit);
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_ONES) == 0;
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = ZstrCompare(StrBegin(&text), "1230") == 0;
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        success = success && (ZstrCompare(StrBegin(&output), "{​{") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        StrAppendFmt(&output, "{}", s);
        success = success && (ZstrCompare(StrBegin(&output), "World") == 0);
        StrDeinit(&s);
    
        StrDeinit(&output);
        StrDeinit(&s);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "0") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "0xDEADBEEF") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "0b10100101") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "0o777") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "2.718280") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "3.1415926536") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "nan") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), " abc ") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&output), "3.140000 Hello 42") == 0);
    
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
                              StrBegin(&output)[5] == 'Z' && StrBegin(&output)[6] == '1' && StrBegin(&output)[7] == '2');
    
        StrDeinit(&output);
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&output);
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return success;
        BitVecDeinit(&bv3);
        BitVecDeinit(&bv_zero);
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        IntDeinit(&bin_val);
        IntDeinit(&oct_val);
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        FloatDeinit(&sci);
        FloatDeinit(&short_v);
        StrDeinit(&output);
        DefaultAllocatorDeinit(&alloc);
        return success;
        StrWriteFmt(&s, "fresh {}", LVAL(42));
        bool ok = (StrLen(&s) == 8) && (StrBegin(&s)[0] == 'f') && (StrBegin(&s)[StrLen(&s) - 1] == '2');
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && StrBegin(&s)[6] == 'A' && StrBegin(&s)[7] == 'A';
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        result = result && (ZstrCompare(StrBegin(&s), "?He!llo.") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "He Worldllo") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrLen(&s2) == 0 && StrBegin(&s2) == NULL);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrLen(&s2) == 6 && ZstrCompare(StrBegin(&s2), " World") == 0);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result = result && (StrLen(&s2) == 0 && StrBegin(&s2) == NULL);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s1);
        StrDeinit(&s2);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello World 2023") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = ZstrCompare(StrBegin(&text), "-12.5") == 0;
    
        StrDeinit(&text);
        FloatAbs(&value);
        text   = FloatToStr(&value);
        result = result && (ZstrCompare(StrBegin(&text), "12.5") == 0);
    
        StrDeinit(&text);
        FloatDeinit(&value);
        DefaultAllocatorDeinit(&alloc);
        bool result = ZstrCompare(StrBegin(&text), "1.23") == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_THREES) == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), "2") == 0;
    
        StrDeinit(&text);
        FloatAdd(&result_value, &a, &whole);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "3.25") == 0);
    
        StrDeinit(&text);
        FloatAdd(&result_value, &a, 2u);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "3.25") == 0);
    
        StrDeinit(&text);
        FloatAdd(&result_value, &a, -1);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "0.25") == 0);
    
        StrDeinit(&text);
        FloatAdd(&result_value, &a, 0.75f);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "2") == 0);
    
        StrDeinit(&text);
        FloatAdd(&result_value, &a, 0.75);
        text   = FloatToStr(&result_value);
        IntDeinit(&whole);
        FloatDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = ZstrCompare(StrBegin(&text), "-0.5") == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_TWOS) == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), "5") == 0;
    
        StrDeinit(&text);
        FloatSub(&result_value, &a, &whole);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "3.5") == 0);
    
        StrDeinit(&text);
        FloatSub(&result_value, &a, 2u);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "3.5") == 0);
    
        StrDeinit(&text);
        FloatSub(&result_value, &a, -2);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "7.5") == 0);
    
        StrDeinit(&text);
        FloatSub(&result_value, &a, 0.5f);
        text   = FloatToStr(&result_value);
        IntDeinit(&whole);
        FloatDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = ZstrCompare(StrBegin(&text), "-2.5") == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_TWOS) == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), "3") == 0;
    
        StrDeinit(&text);
        FloatMul(&result_value, &a, &whole);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "3") == 0);
    
        StrDeinit(&text);
        FloatMul(&result_value, &a, 2u);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "3") == 0);
    
        StrDeinit(&text);
        FloatMul(&result_value, &a, -2);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "-3") == 0);
    
        StrDeinit(&text);
        FloatMul(&result_value, &a, 0.5f);
        text   = FloatToStr(&result_value);
        IntDeinit(&whole);
        FloatDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = ZstrCompare(StrBegin(&text), "0.125") == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_ONES) == 0;
    
        StrDeinit(&text);
        FloatDeinit(&a);
        FloatDeinit(&b);
        bool result = ZstrCompare(StrBegin(&text), "3") == 0;
    
        StrDeinit(&text);
        FloatDiv(&result_value, &a, &whole, 1);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "2.5") == 0);
    
        StrDeinit(&text);
        FloatDiv(&result_value, &a, 3u, 1);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "2.5") == 0);
    
        StrDeinit(&text);
        FloatDiv(&result_value, &a, -3, 1);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "-2.5") == 0);
    
        StrDeinit(&text);
        FloatDiv(&result_value, &a, 0.5f, 1);
        text   = FloatToStr(&result_value);
        result = result && (ZstrCompare(StrBegin(&text), "15") == 0);
    
        StrDeinit(&text);
        FloatDiv(&result_value, &a, 0.5, 1);
        text   = FloatToStr(&result_value);
        IntDeinit(&whole);
        FloatDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (ZstrCompare(StrBegin(&text), "100000000") == 0);
    
        StrDeinit(&text);
        IntDeinit(&a);
        IntDeinit(&b);
        IntDeinit(&result_value);
        IntDeinit(&huge);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        IntDeinit(&preserved);
        IntDeinit(&huge);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        IntDeinit(&value);
        IntDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = ZstrCompare(StrBegin(&text), "79792266297612001") == 0;
    
        StrDeinit(&text);
        IntPow(&result_value, &base, &exponent);
        text   = IntToStr(&result_value);
        IntDeinit(&exponent);
        IntDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        result      = result && (IntToU64(&remainder) == 3);
    
        StrDeinit(&qtext);
        IntDeinit(&dividend);
        IntDeinit(&quotient);
        IntDeinit(&dividend);
        IntDeinit(&result_value);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        IntDeinit(&quotient);
        IntDeinit(&remainder);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        IntDeinit(&value);
        IntDeinit(&next);
        StrDeinit(&text);
        DefaultAllocatorDeinit(&alloc);
        return result;
        if (!ok) {
            FileRemove(out_path);
            StrDeinit(out_path);
        }
        return ok;
        if (!FileIsOpen(&f)) {
            FileRemove(&path);
            StrDeinit(&path);
            DefaultAllocatorDeinit(&alloc);
            return false;
                      ZstrCompare(StrBegin(&body), "hello from file") == 0;
    
        StrDeinit(&body);
        FileRemove(&path);
        StrDeinit(&path);
        StrDeinit(&body);
        FileRemove(&path);
        StrDeinit(&path);
        DefaultAllocatorDeinit(&alloc);
        return result;
        if (!FileIsOpen(&f)) {
            FileRemove(&path);
            StrDeinit(&path);
            DefaultAllocatorDeinit(&alloc);
            return false;
                      ZstrCompare(StrBegin(&body), expected) == 0 && StrCapacity(&body) >= StrLen(&body) + 1;
    
        StrDeinit(&body);
        FileRemove(&path);
        StrDeinit(&path);
        StrDeinit(&body);
        FileRemove(&path);
        StrDeinit(&path);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (StrLen(&s) == 5 && ZstrCompare(StrBegin(&s), "Hello") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Create a Strs object (vector of strings)
        Strs sv = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
    
        // Add some strings
        }
    
        VecDeinit(&sv); // This should call StrDeinit on each element
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = true; // If we got here, the validation didn't crash
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
    
        // Clean up
        StrDeinit(&str);
        BitVecDeinit(&bv);
                 (StrAllocator(&str)->retry_limit == alloc.base.retry_limit) && (ZstrCompare(StrBegin(&str), "101001") == 0);
    
        StrDeinit(&str);
        BitVecDeinit(&bv);
        DefaultAllocatorDeinit(&alloc);
        Str str_obj = BitVecToStr(&bv);
        result      = result && (StrLen(&str_obj) == 0);
        StrDeinit(&str_obj);
    
        // Test converting single bit
        result  = result && (StrLen(&str_obj) == 1);
        result  = result && (StrCmp(&str_obj, "1", 1) == 0);
        StrDeinit(&str_obj);
    
        // Test large conversions
        str_obj = BitVecToStr(&bv);
        result  = result && (StrLen(&str_obj) == 1000);
        StrDeinit(&str_obj);
    
        BitVecDeinit(&bv);
            result = result && (ZstrCompare(StrBegin(&str), patterns[i]) == 0);
    
            StrDeinit(&str);
            BitVecDeinit(&bv);
        }
        Str empty_str = BitVecToStr(&empty);
        result        = result && (StrLen(&empty_str) == 0);
        StrDeinit(&empty_str);
    
        u64 empty_value = BitVecToInteger(&empty);
            Str str = BitVecToStr(&bv);
            result  = result && (ZstrCompare(StrBegin(&str), test_cases[i].pattern) == 0);
            StrDeinit(&str);
    
            // Test integer conversion (may depend on bit order)
        result = result && cross_match;
    
        StrDeinit(&str1);
        StrDeinit(&str2);
        StrDeinit(&str3);
    
        StrDeinit(&str1);
        StrDeinit(&str2);
        StrDeinit(&str3);
        BitVecDeinit(&bv1);
        StrDeinit(&str1);
        StrDeinit(&str2);
        StrDeinit(&str3);
        BitVecDeinit(&bv1);
        BitVecDeinit(&bv2);
        result = result && pattern_correct;
    
        StrDeinit(&large_str);
    
        // Test byte conversion
        result      = result && !city_reachable(&graph, &index, &s_unknown, &s_alpha);
    
        StrDeinit(&s_alpha);
        StrDeinit(&s_beta);
        StrDeinit(&s_gamma);
    
        StrDeinit(&s_alpha);
        StrDeinit(&s_beta);
        StrDeinit(&s_gamma);
        StrDeinit(&s_delta);
        StrDeinit(&s_alpha);
        StrDeinit(&s_beta);
        StrDeinit(&s_gamma);
        StrDeinit(&s_delta);
        StrDeinit(&s_echo);
        StrDeinit(&s_beta);
        StrDeinit(&s_gamma);
        StrDeinit(&s_delta);
        StrDeinit(&s_echo);
        StrDeinit(&s_unknown);
        StrDeinit(&s_gamma);
        StrDeinit(&s_delta);
        StrDeinit(&s_echo);
        StrDeinit(&s_unknown);
        StrDeinit(&s_delta);
        StrDeinit(&s_echo);
        StrDeinit(&s_unknown);
    
        city_reset_visits(&graph);
        bool result = (StrLen(&s) == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (StrLen(&s) == len && ZstrCompareN(StrBegin(&s), test_str, len) == 0 && StrBegin(&s)[len] == '\0');
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (StrLen(&s) == ZstrLen(test_str) && ZstrCompare(StrBegin(&s), test_str) == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (StrLen(&s) == ZstrLen(test_str) && ZstrCompare(StrBegin(&s), test_str) == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
    
        StrDeinit(&src);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&src);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
    
        StrDeinit(&src);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&src);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (ZstrCompare(StrBegin(&s), "Hello, World!") == 0);
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return result;
        bool result = (success && StrLen(&dst) == StrLen(&src) && ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0);
    
        StrDeinit(&src);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&src);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
        return result;
                      ZstrCompare(StrBegin(&dst), StrBegin(&src)) == 0 && dup_allocator_matches && dst_allocator_matches;
    
        StrDeinit(&src);
        StrDeinit(&dup);
        StrDeinit(&dst);
    
        StrDeinit(&src);
        StrDeinit(&dup);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&src);
        StrDeinit(&dup);
        StrDeinit(&dst);
        DefaultAllocatorDeinit(&alloc);
        return result;
    // Test StrDeinit function
    bool test_str_deinit(void) {
        WriteFmt("Testing StrDeinit\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Deinit the string
        StrDeinit(&s);
    
        // Check that the string is deinited correctly
        bool success = (ZstrCompare(StrBegin(&result), "H0e1l2l3o4") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        WriteFmt("  (Index 0 was processed)\n");
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        WriteFmt("  (Index 0 was processed)\n");
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        bool success = (ZstrCompare(StrBegin(&result), "Hello") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&s), "HELLO") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        }
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (StrLen(&empty_result) == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        StrDeinit(&empty_result);
    
        StrDeinit(&s);
        StrDeinit(&result);
        StrDeinit(&empty_result);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&s);
        StrDeinit(&result);
        StrDeinit(&empty_result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&end_result), "World") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        StrDeinit(&end_result);
    
        StrDeinit(&s);
        StrDeinit(&result);
        StrDeinit(&end_result);
        DefaultAllocatorDeinit(&alloc);
        StrDeinit(&s);
        StrDeinit(&result);
        StrDeinit(&end_result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&s), "Hello WORLD") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
        success = success && (ZstrCompare(StrBegin(&s), "HELLO World") == 0);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
    
        StrDeinit(&s);
        StrDeinit(&result);
        DefaultAllocatorDeinit(&alloc);
        return success;
            if (idx > 4) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
            if (idx >= 5) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
            if (idx < 10) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
            if (idx > 4) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
            if (idx < 12) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
            if (idx >= StrLen(&s)) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
            if (idx > 3) {
                LOG_ERROR("Should've terminated");
                StrDeinit(&s);
                DefaultAllocatorDeinit(&alloc);
                return false;
        }
    
        StrDeinit(&s);
        DefaultAllocatorDeinit(&alloc);
        return true;
        bool ok = (rc == ARG_RUN_OK) && StrLen(&name) == 5 && StrBegin(&name)[0] == 'a' && StrBegin(&name)[4] == 'e';
        ArgParseDeinit(&p);
        StrDeinit(&name);
        DefaultAllocatorDeinit(&a);
        return ok;
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            Abort();                                                                                                       \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            Abort();                                                                                                       \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
    
    typedef struct PdbCacheEntry {
        Str  module_path; // owned; cleaned via StrDeinit
        u64  module_base; // last-seen runtime load base
        Pe   pe;
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') {                                                 \
                    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        StrDeinit(&key);                                                                                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                    si = UNPL(read_si);                                                                                    \
                }                                                                                                          \
                StrDeinit(&key);                                                                                           \
                si = JSkipWhitespace(si);                                                                                  \
                                                                                                                           \
Last updated on