Skip to content

LOG_FATAL

Description

on the diagnostic channel before Abort() runs.

…[in] : Format string and arguments.

Success

Message logged and program aborted via Abort()

Failure

Logging may fail silently, but Abort() will still execute

Usage example (Cross-references)

Usage examples (Cross-references)
    void ValidateAllocator(const Allocator *self) {
        if (!self) {
            LOG_FATAL("NULL allocator pointer");
        }
        if (self->__magic == 0u) {
        }
        if (self->__magic == 0u) {
            LOG_FATAL("Allocator uninitialized (__magic is zero)");
        }
        if (!self->allocate || !self->resize || !self->remap || !self->deallocate) {
        }
        if (!self->allocate || !self->resize || !self->remap || !self->deallocate) {
            LOG_FATAL("Allocator missing required function pointers");
        }
        if (!allocator_alignment_is_pow2(self->alignment)) {
        }
        if (!allocator_alignment_is_pow2(self->alignment)) {
            LOG_FATAL("Allocator alignment must be a power of two > 0");
        }
    }
    
        if (!p1 || !p2) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!dst || !src) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!dst || !src) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!dst) {
            LOG_FATAL("Invalid arguments");
        }
    size ZstrLen(Zstr str) {
        if (!str) {
            LOG_FATAL("Invalid arguments");
        }
    i32 ZstrCompare(Zstr s1, Zstr s2) {
        if (!s1 || !s2) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!key || !*key) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!a || !b || !*a || !*b) {
            LOG_FATAL("Invalid arguments");
        }
    i32 ZstrCompareN(Zstr s1, Zstr s2, size n) {
        if (!s1 || !s2) {
            LOG_FATAL("Invalid arguments");
        }
    i32 ZstrCompareIgnoreCase(Zstr s1, Zstr s2) {
        if (!s1 || !s2) {
            LOG_FATAL("Invalid arguments");
        }
        while (*s1) {
    i32 ZstrCompareNIgnoreCase(Zstr s1, Zstr s2, size n) {
        if (!s1 || !s2) {
            LOG_FATAL("Invalid arguments");
        }
        size i = 0;
    Zstr ZstrFindChar(Zstr str, char ch) {
        if (!str) {
            LOG_FATAL("Invalid arguments");
        }
    Zstr zstr_dup_n(Zstr src, size n, Allocator *alloc) {
        if (!src || !alloc) {
            LOG_FATAL("Invalid arguments");
        }
    Zstr zstr_dup(Zstr src, Allocator *alloc) {
        if (!src) {
            LOG_FATAL("Invalid arguments");
        }
        return zstr_dup_n(src, ZstrLen(src), alloc);
    
        if (!dst || !src || !*src || !alloc) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!zs || !alloc) {
            LOG_FATAL("Invalid arguments");
        }
    Zstr ZstrFindSubstring(Zstr haystack, Zstr needle) {
        if (!needle) {
            LOG_FATAL("Invalid arguments");
        }
        return ZstrFindSubstringN(haystack, needle, ZstrLen(needle));
    Zstr ZstrFindSubstringN(Zstr haystack, Zstr needle, size needle_len) {
        if (!haystack || !needle) {
            LOG_FATAL("Invalid arguments");
        }
        if (needle_len == 0) {
    static bool parse_format_spec(Zstr spec, u32 len, FmtInfo *fi) {
        if (!spec || !fi) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool str_append_fmt(Str *o, Zstr fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
                    }
    #else
                    LOG_FATAL("Invalid writer or data pointer");
    #endif
                }
    bool str_write_fmt(Str *o, Zstr fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool str_patch_fmt(Str *o, size offset, Zstr fmt, TypeSpecificIO *args, u64 argc) {
        if (!o || !fmt) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    
        if (!stream || !fmtstr) {
            LOG_FATAL("Invalid arguments");
            DefaultAllocatorDeinit(&scratch);
            return false;
    Zstr str_read_fmt(Zstr input, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
        if (!input || !fmtstr) {
            LOG_FATAL("Invalid arguments");
        }
    bool buf_read_fmt(BufIter *iter, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
        if (!iter || !fmtstr) {
            LOG_FATAL("buf_read_fmt: NULL iter or fmtstr");
        }
        while (StrIterPeek(&fsi, &fc)) {
            if (fc != '{') {
                LOG_FATAL("buf_read_fmt: stray '{c}' in binary fmt; only {​{<Nr}} / {​{>Nr}} allowed", (u32)(u8)fc);
            }
            StrIterMustNext(&fsi); // step over '{'
            }
            if (sc != '}') {
                LOG_FATAL("buf_read_fmt: unterminated {​{ in fmt");
            }
            u32 spec_len = (u32)(StrIterRemainingLength(&spec_start_fsi) - StrIterRemainingLength(&fsi));
            }
            if (!(fmt_info.flags & FMT_FLAG_RAW)) {
                LOG_FATAL("buf_read_fmt: only raw ({​{<Nr}}/{​{>Nr}}) specs allowed");
            }
            if (fmt_info.width != 1 && fmt_info.width != 2 && fmt_info.width != 4 && fmt_info.width != 8) {
            }
            if (fmt_info.width != 1 && fmt_info.width != 2 && fmt_info.width != 4 && fmt_info.width != 8) {
                LOG_FATAL("buf_read_fmt: raw width must be 1/2/4/8 (got {})", (u64)fmt_info.width);
            }
            // Bounds check in iter space; pointer arithmetic stays inside the buffer.
            }
            if (arg_index >= argc) {
                LOG_FATAL("buf_read_fmt: too few arguments for format string");
            }
            TypeSpecificIO *io = &argv[arg_index++];
            TypeSpecificIO *io = &argv[arg_index++];
            if (!io->reader) {
                LOG_FATAL("buf_read_fmt: argument {} has no reader", arg_index - 1);
            }
                var_width = 8;
            } else {
                LOG_FATAL("buf_read_fmt: unsupported variable type at arg {}", arg_index - 1);
            }
            if (fmt_info.width != var_width) {
            }
            if (fmt_info.width != var_width) {
                LOG_FATAL(
                    "buf_read_fmt: spec width {} doesn't match variable width {} at arg {}",
                    (u64)fmt_info.width,
    
        if (arg_index != argc) {
            LOG_FATAL("buf_read_fmt: {} unused argument(s) at end of format", argc - arg_index);
        }
        return true;
    static bool render_one_raw_field(Str *out, FmtInfo *fmt_info, TypeSpecificIO *io, u64 arg_index) {
        if (!io->writer) {
            LOG_FATAL("buf_*_fmt: argument {} has no writer", arg_index);
        }
        void *write_fn  = (void *)io->writer;
            var_width = 8;
        } else {
            LOG_FATAL("buf_*_fmt: unsupported variable type at arg {}", arg_index);
        }
        if (fmt_info->width != var_width) {
        }
        if (fmt_info->width != var_width) {
            LOG_FATAL(
                "buf_*_fmt: spec width {} doesn't match variable width {} at arg {}",
                (u64)fmt_info->width,
        while (StrIterPeek(&fsi, &fc)) {
            if (fc != '{') {
                LOG_FATAL("buf_*_fmt: stray '{c}' in binary fmt; only {​{<Nr}} / {​{>Nr}} allowed", (u32)(u8)fc);
            }
            StrIterMustNext(&fsi); // step over '{'
            }
            if (sc != '}') {
                LOG_FATAL("buf_*_fmt: unterminated {​{ in fmt");
            }
            u32 spec_len = (u32)(StrIterRemainingLength(&spec_start_fsi) - StrIterRemainingLength(&fsi));
            }
            if (!(fmt_info.flags & FMT_FLAG_RAW)) {
                LOG_FATAL("buf_*_fmt: only raw ({​{<Nr}}/{​{>Nr}}) specs allowed");
            }
            if (fmt_info.width != 1 && fmt_info.width != 2 && fmt_info.width != 4 && fmt_info.width != 8) {
            }
            if (fmt_info.width != 1 && fmt_info.width != 2 && fmt_info.width != 4 && fmt_info.width != 8) {
                LOG_FATAL("buf_*_fmt: raw width must be 1/2/4/8 (got {})", (u64)fmt_info.width);
            }
            if (arg_index >= argc) {
            }
            if (arg_index >= argc) {
                LOG_FATAL("buf_*_fmt: too few arguments for format string");
            }
            TypeSpecificIO *io = &argv[arg_index++];
        }
        if (arg_index != argc) {
            LOG_FATAL("buf_*_fmt: {} unused argument(s) at end of format", argc - arg_index);
        }
        return true;
    bool buf_append_fmt(Buf *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
        if (!out || !fmtstr) {
            LOG_FATAL("buf_append_fmt: NULL out or fmtstr");
        }
        // The raw-write helpers (_write_rN) emit into a Str. Buf is Vec(u8)
    bool buf_write_fmt(Buf *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
        if (!out || !fmtstr) {
            LOG_FATAL("buf_write_fmt: NULL out or fmtstr");
        }
        VecClear(out);
    bool buf_patch_fmt(Buf *out, size offset, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
        if (!out || !fmtstr) {
            LOG_FATAL("buf_patch_fmt: NULL out or fmtstr");
        }
        // Render into a scratch Str so we know the byte count before
        if (!file || !fmtstr) {
            DefaultAllocatorDeinit(&scratch);
            LOG_FATAL("Invalid arguments");
        }
    static inline bool write_int_as_chars(Str *o, FormatFlags flags, u64 value, size num_bytes) {
        if (!o || !num_bytes || num_bytes > 8) {
            LOG_FATAL("Invalid arguments");
        }
    static inline bool write_char_internal(Str *o, FormatFlags flags, Zstr vs, size len) {
        if (!o || !vs || !len) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!input) {
            LOG_FATAL("Invalid arguments");
        }
    static inline Zstr read_chars_internal(Zstr i, u8 *buffer, size buffer_size, FmtInfo *fmt_info) {
        if (!i || !buffer || !buffer_size) {
            LOG_FATAL("Invalid arguments");
        }
    bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s) {
        if (!o || !s || !fmt_info) {
            LOG_FATAL("Invalid arguments");
        }
    bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s) {
        if (!o || !s || !*s || !fmt_info) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    
        if (!arg) {
            LOG_FATAL("Invalid arguments");
        }
    bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    
        if (!o || !fmt_info || !value) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    
        if (float_fmt_uses_unsupported_flags(fmt_info)) {
            LOG_FATAL("Float only supports decimal and scientific formatting");
        }
    Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s) {
        if (!i || !s)
            LOG_FATAL("Invalid arguments");
    
        ValidateStr(s);
        if (!i || !v) {
            DefaultAllocatorDeinit(&scratch);
            LOG_FATAL("Invalid arguments");
        }
        if (!i || !v) {
            DefaultAllocatorDeinit(&scratch);
            LOG_FATAL("Invalid arguments");
        }
            if (!i || !v) {                                                                                                \
                DefaultAllocatorDeinit(&scratch);                                                                          \
                LOG_FATAL("Invalid arguments");                                                                            \
            }                                                                                                              \
                                                                                                                           \
        (void)fmt_info;
        (void)out;
        LOG_FATAL("Zstr reads require explicit allocator provenance; use ZstrIO(zstr, alloc) instead");
        return i;
    }
    
        if (!i || !arg || !arg->value || !arg->allocator) {
            LOG_FATAL("Invalid arguments");
        }
    bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv) {
        if (!o || !fmt_info || !bv) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value) {
        if (!o || !fmt_info || !value) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
        (void)fmt_info; // Unused parameter
        if (!i || !bv) {
            LOG_FATAL("Invalid arguments");
            return i;
        }
    Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value) {
        if (!i || !value) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!i || !value) {
            LOG_FATAL("Invalid arguments");
        }
        if (!i || !v) {
            DefaultAllocatorDeinit(&scratch);
            LOG_FATAL("Invalid arguments");
        }
    static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
    static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
            case ENDIAN_NATIVE :
            default : {
                LOG_FATAL("Invalid endianness");
                return false;
            }
    static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
            case ENDIAN_NATIVE :
            default : {
                LOG_FATAL("Invalid endianness");
                return false;
            }
    static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v) {
        if (!o || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
            return false;
        }
            case ENDIAN_NATIVE :
            default : {
                LOG_FATAL("Invalid endianness");
                return false;
            }
    static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v) {
        if (!i || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
        }
    static Zstr _read_r16(Zstr i, FmtInfo *fmt_info, u16 *v) {
        if (!i || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
        }
            case ENDIAN_NATIVE :
            default :
                LOG_FATAL("Invalid endianness");
        }
    static Zstr _read_r32(Zstr i, FmtInfo *fmt_info, u32 *v) {
        if (!i || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
        }
            case ENDIAN_NATIVE :
            default :
                LOG_FATAL("Invalid endianness");
        }
    static Zstr _read_r64(Zstr i, FmtInfo *fmt_info, u64 *v) {
        if (!i || !fmt_info || !v) {
            LOG_FATAL("Invalid arguments");
        }
            case ENDIAN_NATIVE :
            default :
                LOG_FATAL("Invalid endianness");
        }
    #if PLATFORM_WINDOWS
        if (BCryptGenRandom(NULL, p, (unsigned long)rem, 2) != 0) { // BCRYPT_USE_SYSTEM_PREFERRED_RNG = 2
            LOG_FATAL("Prng: BCryptGenRandom failed");
        }
    #elif FEATURE_DIRECT_SYSCALL
            long ret   = direct_sys2(MISRA_SYS_getentropy, (long)(u64)p, chunk);
            if (ret < 0) {
                LOG_FATAL("Prng: getentropy failed");
            }
            p   += chunk;
                    continue;
                }
                LOG_FATAL("Prng: getrandom failed");
            }
            p   += (u64)ret;
            return;
        }
        LOG_FATAL("Prng: no entropy source available");
    #endif
    }
    void arg_register(ArgParse *self, ArgRole role, Zstr short_name, Zstr long_name, Zstr help, ArgTarget target) {
        if (!self)
            LOG_FATAL("arg_register: NULL parser");
        if (target.kind == ARG_KIND_INVALID) {
            LOG_FATAL(
            LOG_FATAL("arg_register: NULL parser");
        if (target.kind == ARG_KIND_INVALID) {
            LOG_FATAL(
                "arg_register: unsupported target type for '{}'",
                long_name ? long_name : (short_name ? short_name : "<unnamed>")
        }
        if (role == ARG_ROLE_FLAG && target.kind != ARG_KIND_BOOL) {
            LOG_FATAL("arg_register: ArgFlag '{}' requires a bool* target", long_name ? long_name : short_name);
        }
        if (role == ARG_ROLE_COUNT && target.kind != ARG_KIND_U8 && target.kind != ARG_KIND_U16 &&
        if (role == ARG_ROLE_COUNT && target.kind != ARG_KIND_U8 && target.kind != ARG_KIND_U16 &&
            target.kind != ARG_KIND_U32 && target.kind != ARG_KIND_U64) {
            LOG_FATAL("arg_register: ArgCount '{}' requires a u8/u16/u32/u64* target", long_name ? long_name : short_name);
        }
        if (role == ARG_ROLE_POSITIONAL && !long_name) {
        }
        if (role == ARG_ROLE_POSITIONAL && !long_name) {
            LOG_FATAL("arg_register: ArgPositional needs a non-NULL name");
        }
        if (role != ARG_ROLE_POSITIONAL && !short_name && !long_name) {
        }
        if (role != ARG_ROLE_POSITIONAL && !short_name && !long_name) {
            LOG_FATAL("arg_register: option needs at least one of short/long name");
        }
    static void page_validate_self_structural(const PageAllocator *pg) {
        if (!pg->base.allocate || !pg->base.resize || !pg->base.remap || !pg->base.deallocate) {
            LOG_FATAL("PageAllocator: vtable function pointer is NULL");
        }
        if (pg->base.alignment == 0 || (pg->base.alignment & (pg->base.alignment - 1)) != 0) {
        }
        if (pg->base.alignment == 0 || (pg->base.alignment & (pg->base.alignment - 1)) != 0) {
            LOG_FATAL("PageAllocator: alignment {} is not a positive power of two", (u64)pg->base.alignment);
        }
        if (pg->len > pg->cap) {
        }
        if (pg->len > pg->cap) {
            LOG_FATAL("PageAllocator: len {} exceeds cap {}", (u64)pg->len, (u64)pg->cap);
        }
        if ((pg->entries == NULL) != (pg->cap == 0)) {
        }
        if ((pg->entries == NULL) != (pg->cap == 0)) {
            LOG_FATAL("PageAllocator: entries / cap mismatch (entries={x}, cap={})", (u64)pg->entries, (u64)pg->cap);
        }
        if (pg->len > 0 && !pg->entries) {
        }
        if (pg->len > 0 && !pg->entries) {
            LOG_FATAL("PageAllocator: len {} with NULL entries", (u64)pg->len);
        }
        if ((pg->entries == NULL) != (pg->entries_bytes == 0)) {
        }
        if ((pg->entries == NULL) != (pg->entries_bytes == 0)) {
            LOG_FATAL("PageAllocator: entries / entries_bytes mismatch");
        }
        if (pg->entries && pg->entries_bytes < (size)pg->cap * sizeof(PageEntry)) {
        }
        if (pg->entries && pg->entries_bytes < (size)pg->cap * sizeof(PageEntry)) {
            LOG_FATAL(
                "PageAllocator: entries_bytes {} too small for cap {} (need {})",
                (u64)pg->entries_bytes,
        // Same invariants for the retention table.
        if (pg->free_len > pg->free_cap) {
            LOG_FATAL("PageAllocator: free_len {} exceeds free_cap {}", (u64)pg->free_len, (u64)pg->free_cap);
        }
        if ((pg->free_entries == NULL) != (pg->free_cap == 0)) {
        }
        if ((pg->free_entries == NULL) != (pg->free_cap == 0)) {
            LOG_FATAL(
                "PageAllocator: free_entries / free_cap mismatch ({x} / {})",
                (u64)pg->free_entries,
        }
        if (pg->free_len > 0 && !pg->free_entries) {
            LOG_FATAL("PageAllocator: free_len {} with NULL free_entries", (u64)pg->free_len);
        }
        if ((pg->free_entries == NULL) != (pg->free_entries_bytes == 0)) {
        }
        if ((pg->free_entries == NULL) != (pg->free_entries_bytes == 0)) {
            LOG_FATAL("PageAllocator: free_entries / free_entries_bytes mismatch");
        }
        if (pg->free_entries) {
    static void page_validate_self(const PageAllocator *pg) {
        if (!pg) {
            LOG_FATAL("PageAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(pg->base.__magic, PAGE_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(pg->base.__magic, PAGE_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to page_allocator_* is not a PageAllocator");
        }
        if (!(pg->base.__magic & MAGIC_VALIDATED_BIT)) {
        u32 idx = page_find_idx_sorted(self->entries, self->len, ptr);
        if (idx == (u32)-1) {
            LOG_FATAL("page_remap: foreign or already-freed ptr {x}", (u64)ptr);
            return NULL;
        }
            // fast alloc-side exact-match lookup), so a ptr-keyed bsearch
            // isn't available to disambiguate.
            LOG_FATAL("page_free: foreign or already-freed ptr {x}", (u64)ptr);
            return 0;
        }
    static void budget_validate_self_structural(const BudgetAllocator *self) {
        if (!self->base.allocate || !self->base.resize || !self->base.remap || !self->base.deallocate) {
            LOG_FATAL("BudgetAllocator: vtable function pointer is NULL");
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
            LOG_FATAL("BudgetAllocator: alignment {} is not a positive power of two", (u64)self->base.alignment);
        }
        if (!self->buf || self->buf_bytes == 0) {
        }
        if (!self->buf || self->buf_bytes == 0) {
            LOG_FATAL("BudgetAllocator: NULL or zero-byte backing buffer");
        }
        if (!self->bitmap || self->bitmap_words == 0) {
        }
        if (!self->bitmap || self->bitmap_words == 0) {
            LOG_FATAL("BudgetAllocator: NULL or zero-word bitmap");
        }
        if (!self->slots || self->slot_count == 0) {
        }
        if (!self->slots || self->slot_count == 0) {
            LOG_FATAL("BudgetAllocator: NULL or zero-count slot region");
        }
        if (self->slot_size == 0) {
        }
        if (self->slot_size == 0) {
            LOG_FATAL("BudgetAllocator: slot_size is 0");
        }
        // Bitmap covers at least slot_count bits.
        // Bitmap covers at least slot_count bits.
        if ((u64)self->bitmap_words * 64u < (u64)self->slot_count) {
            LOG_FATAL(
                "BudgetAllocator: bitmap_words {} too small for slot_count {} (need {})",
                (u64)self->bitmap_words,
        const u8 *buf_end = self->buf + self->buf_bytes;
        if ((const u8 *)self->bitmap < self->buf || (const u8 *)self->bitmap >= buf_end) {
            LOG_FATAL("BudgetAllocator: bitmap pointer outside buf region");
        }
        if (self->slots < self->buf || self->slots > buf_end) {
        }
        if (self->slots < self->buf || self->slots > buf_end) {
            LOG_FATAL("BudgetAllocator: slots pointer outside buf region");
        }
        if ((u64)self->slot_count * (u64)self->slot_size > (u64)(buf_end - self->slots)) {
        }
        if ((u64)self->slot_count * (u64)self->slot_size > (u64)(buf_end - self->slots)) {
            LOG_FATAL(
                "BudgetAllocator: slots region overruns buf (need {} bytes, have {})",
                (u64)self->slot_count * (u64)self->slot_size,
        // Bitmap region must precede the slot region (init lays them out that way).
        if ((const u8 *)self->bitmap >= self->slots) {
            LOG_FATAL("BudgetAllocator: bitmap region must precede slot region");
        }
    }
    static void budget_validate_self(const BudgetAllocator *self) {
        if (!self) {
            LOG_FATAL("BudgetAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(self->base.__magic, BUDGET_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->base.__magic, BUDGET_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to budget_allocator_* is not a BudgetAllocator");
        }
        if (!(self->base.__magic & MAGIC_VALIDATED_BIT)) {
        u32 b = (u32)((u64)idx & 63u);
        if (self->bitmap[w] & ((u64)1 << b)) {
            LOG_FATAL("BudgetAllocator bitmap corruption: idx {} bit unexpectedly set", (u64)idx);
        }
        self->bitmap[w] |= ((u64)1 << b);
    
        if (p < self->slots || p >= end) {
            LOG_FATAL("budget_free: foreign ptr {x} not in slot region", (u64)p);
            return 0;
        }
        size off = (size)(p - self->slots);
        if (off % self->slot_size != 0) {
            LOG_FATAL("budget_free: misaligned ptr {x} (slot size {})", (u64)p, (u64)self->slot_size);
            return 0;
        }
        u32  b   = (u32)(idx & 63u);
        if (!(self->bitmap[w] & ((u64)1 << b))) {
            LOG_FATAL("budget_free: double-free of {x} (idx {})", (u64)p, (u64)idx);
            return 0;
        }
    static void heap_validate_self_structural(const HeapAllocator *h) {
        if (!h->base.allocate || !h->base.resize || !h->base.remap || !h->base.deallocate) {
            LOG_FATAL("HeapAllocator: vtable function pointer is NULL");
        }
        if (h->base.alignment == 0 || (h->base.alignment & (h->base.alignment - 1)) != 0) {
        }
        if (h->base.alignment == 0 || (h->base.alignment & (h->base.alignment - 1)) != 0) {
            LOG_FATAL("HeapAllocator: alignment {} is not a positive power of two", (u64)h->base.alignment);
        }
        if (h->pages_count > h->pages_cap) {
        }
        if (h->pages_count > h->pages_cap) {
            LOG_FATAL("HeapAllocator: pages_count {} exceeds pages_cap {}", (u64)h->pages_count, (u64)h->pages_cap);
        }
        if ((h->pages == NULL) != (h->pages_cap == 0)) {
        }
        if ((h->pages == NULL) != (h->pages_cap == 0)) {
            LOG_FATAL("HeapAllocator: pages / pages_cap mismatch ({x} / {})", (u64)h->pages, (u64)h->pages_cap);
        }
        if (h->pages_cap != 0 && (h->pages_cap & (h->pages_cap - 1)) != 0) {
        }
        if (h->pages_cap != 0 && (h->pages_cap & (h->pages_cap - 1)) != 0) {
            LOG_FATAL("HeapAllocator: pages_cap {} is not a power of two", (u64)h->pages_cap);
        }
        if (h->xl_in_use_len > h->xl_in_use_cap) {
        }
        if (h->xl_in_use_len > h->xl_in_use_cap) {
            LOG_FATAL(
                "HeapAllocator: xl_in_use_len {} exceeds xl_in_use_cap {}",
                (u64)h->xl_in_use_len,
        }
        if ((h->xl_in_use == NULL) != (h->xl_in_use_cap == 0)) {
            LOG_FATAL(
                "HeapAllocator: xl_in_use / xl_in_use_cap mismatch ({x} / {})",
                (u64)h->xl_in_use,
        }
        if (h->xl_freed_len > h->xl_freed_cap) {
            LOG_FATAL("HeapAllocator: xl_freed_len {} exceeds xl_freed_cap {}", (u64)h->xl_freed_len, (u64)h->xl_freed_cap);
        }
        if ((h->xl_freed == NULL) != (h->xl_freed_cap == 0)) {
        }
        if ((h->xl_freed == NULL) != (h->xl_freed_cap == 0)) {
            LOG_FATAL("HeapAllocator: xl_freed / xl_freed_cap mismatch ({x} / {})", (u64)h->xl_freed, (u64)h->xl_freed_cap);
        }
        if (h->pages) {
    static FORCE_INLINE void heap_validate_self(const HeapAllocator *h) {
        if (!h) {
            LOG_FATAL("HeapAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(h->base.__magic, HEAP_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(h->base.__magic, HEAP_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to heap_allocator_* is not a HeapAllocator");
        }
        if (!(h->base.__magic & MAGIC_VALIDATED_BIT)) {
        }
        // Unreachable: caller verified there's a free slot.
        LOG_FATAL("HeapAllocator: take_slot on a full page (class {}, page {x})", (u64)cls, (u64)d->page);
        return NULL;
    }
    
        if (off >= (u64)slot_size * heap_class_slots[cls]) {
            LOG_FATAL("heap_free: ptr {x} past slot region (class size {})", (u64)ptr, (u64)slot_size);
            return;
        }
        }
        if (off % slot_size != 0u) {
            LOG_FATAL("heap_free: misaligned ptr {x} for slot size {}", (u64)ptr, (u64)slot_size);
            return;
        }
        u64 mask     = (u64)1 << bit;
        if (!(d->bitmap[w] & mask)) {
            LOG_FATAL("heap_free: double-free of {x} (class size {}, slot {})", (u64)ptr, (u64)slot_size, (u64)slot_idx);
            return;
        }
        size cur = heap_recover_size(self, ptr, &idx, &is_xl);
        if (!cur) {
            LOG_FATAL("heap_remap: foreign or already-freed ptr {x}", (u64)ptr);
            return NULL;
        }
        size cur = heap_recover_size(self, ptr, &idx, &is_xl);
        if (!cur) {
            LOG_FATAL("heap_free: foreign or already-freed ptr {x}", (u64)ptr);
            return 0;
        }
    static void debug_validate_self_structural(const DebugAllocator *self) {
        if (!self->base.allocate || !self->base.resize || !self->base.remap || !self->base.deallocate) {
            LOG_FATAL("DebugAllocator: vtable function pointer is NULL");
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
            LOG_FATAL("DebugAllocator: alignment {} is not a positive power of two", (u64)self->base.alignment);
        }
        // Embedded backing allocators must themselves be sane. We don't
        // masks the memo bit so neither memoized state breaks the check.
        if (!MAGIC_MATCHES(self->heap.base.__magic, HEAP_ALLOCATOR_MAGIC)) {
            LOG_FATAL("DebugAllocator: embedded heap has bad magic");
        }
        if (!MAGIC_MATCHES(self->meta.base.__magic, HEAP_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->meta.base.__magic, HEAP_ALLOCATOR_MAGIC)) {
            LOG_FATAL("DebugAllocator: embedded meta has bad magic");
        }
        if (!MAGIC_MATCHES(self->page.base.__magic, PAGE_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->page.base.__magic, PAGE_ALLOCATOR_MAGIC)) {
            LOG_FATAL("DebugAllocator: embedded page has bad magic");
        }
        if (!MAGIC_MATCHES(self->live.__magic, MAP_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->live.__magic, MAP_MAGIC)) {
            LOG_FATAL("DebugAllocator: live map has bad magic");
        }
        if (!MAGIC_MATCHES(self->freed.__magic, VEC_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->freed.__magic, VEC_MAGIC)) {
            LOG_FATAL("DebugAllocator: freed vec has bad magic");
        }
        // bytes_in_use must be consistent with live: if live is non-empty
        // every byte has been returned.
        if (MapPairCount(&self->live) == 0 && self->bytes_in_use != 0) {
            LOG_FATAL("DebugAllocator: bytes_in_use {} with no live records", (u64)self->bytes_in_use);
        }
        u64 cur_tid = debug_current_tid();
        u64 cur_tid = debug_current_tid();
        if (self->creator_tid != cur_tid) {
            LOG_FATAL(
                "DebugAllocator: cross-thread use detected (created on {x}, called from {x}). "
                "Each thread must use its own DebugAllocator instance.",
    static void debug_validate_self(const DebugAllocator *self) {
        if (!self) {
            LOG_FATAL("DebugAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(self->base.__magic, DEBUG_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->base.__magic, DEBUG_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to debug_allocator_* is not a DebugAllocator");
        }
        // Lazy-bind the embedded Map/Vec's `.allocator` pointer. The
                debug_emit_trace(fe->alloc_trace, fe->alloc_trace_n, "alloc", ALLOCATOR_OF(&self->meta));
                debug_emit_trace(fe->free_trace, fe->free_trace_n, "first-free", ALLOCATOR_OF(&self->meta));
                LOG_FATAL("DebugAllocator: double-free of {x}", (u64)ptr);
                return 0;
            }
        u64 cur_tid = debug_current_tid();
        if (self->creator_tid != cur_tid) {
            LOG_FATAL(
                "DebugAllocator: Deinit called from a different thread (created on {x}, called from {x}).",
                self->creator_tid,
    static void arena_validate_self_structural(const ArenaAllocator *self) {
        if (!self->base.allocate || !self->base.resize || !self->base.remap || !self->base.deallocate) {
            LOG_FATAL("ArenaAllocator: vtable function pointer is NULL");
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
            LOG_FATAL("ArenaAllocator: alignment {} is not a positive power of two", (u64)self->base.alignment);
        }
        if ((self->head == NULL) != (self->tail == NULL)) {
        }
        if ((self->head == NULL) != (self->tail == NULL)) {
            LOG_FATAL("ArenaAllocator: head/tail mismatch ({x} / {x})", (u64)self->head, (u64)self->tail);
        }
        if ((self->last_ptr == NULL) != (self->last_size == 0)) {
        }
        if ((self->last_ptr == NULL) != (self->last_size == 0)) {
            LOG_FATAL("ArenaAllocator: last_ptr/last_size mismatch ({x} / {})", (u64)self->last_ptr, (u64)self->last_size);
        }
        if (self->last_ptr && !self->head) {
        }
        if (self->last_ptr && !self->head) {
            LOG_FATAL("ArenaAllocator: last_ptr is set but chunk list is empty");
        }
    }
    static void arena_validate_self(const ArenaAllocator *self) {
        if (!self) {
            LOG_FATAL("ArenaAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(self->base.__magic, ARENA_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->base.__magic, ARENA_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to arena_allocator_* is not an ArenaAllocator");
        }
        if (!(self->base.__magic & MAGIC_VALIDATED_BIT)) {
        // below carry the distinction.
        if (!arena_owns_pointer(self, ptr)) {
            LOG_FATAL("arena_remap: foreign ptr {x} (not in any chunk)", (u64)ptr);
            return NULL;
        }
        }
        if (self->last_ptr != ptr) {
            LOG_FATAL(
                "arena_remap: ptr {x} is not the most recent bump; bump allocators "
                "cannot remap mid-stream allocations. Use HeapAllocator for "
        // verify ownership -- a foreign pointer is a caller bug and aborts.
        if (!arena_owns_pointer(self, ptr)) {
            LOG_FATAL("arena_free: foreign ptr {x} (not in any chunk)", (u64)ptr);
            return 0;
        }
    static void slab_validate_self_structural(const SlabAllocator *self) {
        if (!self->base.allocate || !self->base.resize || !self->base.remap || !self->base.deallocate) {
            LOG_FATAL("SlabAllocator: vtable function pointer is NULL");
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
        }
        if (self->base.alignment == 0 || (self->base.alignment & (self->base.alignment - 1)) != 0) {
            LOG_FATAL("SlabAllocator: alignment {} is not a positive power of two", (u64)self->base.alignment);
        }
        if (self->slot_size == 0) {
        }
        if (self->slot_size == 0) {
            LOG_FATAL("SlabAllocator: slot_size is 0");
        }
        if ((self->slot_size & (self->slot_size - 1)) != 0) {
        }
        if ((self->slot_size & (self->slot_size - 1)) != 0) {
            LOG_FATAL("SlabAllocator: slot_size {} is not a power of two", (u64)self->slot_size);
        }
        if (self->slot_size < 16) {
        }
        if (self->slot_size < 16) {
            LOG_FATAL("SlabAllocator: slot_size {} below 16-byte minimum", (u64)self->slot_size);
        }
        if (self->slot_size_shift == 0 || ((size)1 << self->slot_size_shift) != self->slot_size) {
        }
        if (self->slot_size_shift == 0 || ((size)1 << self->slot_size_shift) != self->slot_size) {
            LOG_FATAL(
                "SlabAllocator: slot_size_shift {} disagrees with slot_size {}",
                (u64)self->slot_size_shift,
        }
        if ((self->slabs == NULL) != (self->slabs_cap == 0)) {
            LOG_FATAL("SlabAllocator: slabs / slabs_cap mismatch ({x} / {})", (u64)self->slabs, (u64)self->slabs_cap);
        }
        if ((self->bitmaps == NULL) != (self->slabs_cap == 0)) {
        }
        if ((self->bitmaps == NULL) != (self->slabs_cap == 0)) {
            LOG_FATAL("SlabAllocator: bitmaps / slabs_cap mismatch ({x} / {})", (u64)self->bitmaps, (u64)self->slabs_cap);
        }
        if (self->slabs_len > self->slabs_cap) {
        }
        if (self->slabs_len > self->slabs_cap) {
            LOG_FATAL("SlabAllocator: slabs_len {} exceeds slabs_cap {}", (u64)self->slabs_len, (u64)self->slabs_cap);
        }
    }
    static FORCE_INLINE void slab_validate_self(const SlabAllocator *self) {
        if (!self) {
            LOG_FATAL("SlabAllocator: NULL self");
        }
        if (!MAGIC_MATCHES(self->base.__magic, SLAB_ALLOCATOR_MAGIC)) {
        }
        if (!MAGIC_MATCHES(self->base.__magic, SLAB_ALLOCATOR_MAGIC)) {
            LOG_FATAL("type-confusion: allocator passed to slab_allocator_* is not a SlabAllocator");
        }
        if (!(self->base.__magic & MAGIC_VALIDATED_BIT)) {
        size page_size = os_page_size();
        if (slab->slot_size < 16u) {
            LOG_FATAL("SlabAllocator: slot_size {} below 16-byte minimum", (u64)slab->slot_size);
        }
        if (slab->slot_size > page_size) {
        }
        if (slab->slot_size > page_size) {
            LOG_FATAL("SlabAllocator: slot_size {} exceeds page size {}", (u64)slab->slot_size, (u64)page_size);
        }
        if ((slab->slot_size & (slab->slot_size - 1)) != 0) {
        }
        if ((slab->slot_size & (slab->slot_size - 1)) != 0) {
            LOG_FATAL("SlabAllocator: slot_size {} is not a power of two", (u64)slab->slot_size);
        }
        if (slab->slot_size_shift == 0 || ((size)1u << slab->slot_size_shift) != slab->slot_size) {
        }
        if (slab->slot_size_shift == 0 || ((size)1u << slab->slot_size_shift) != slab->slot_size) {
            LOG_FATAL(
                "SlabAllocator: slot_size_shift {} disagrees with slot_size {}",
                (u64)slab->slot_size_shift,
            // 16320 slots per slab; way past anything sensible for our
            // slot-size range.
            LOG_FATAL("SlabAllocator: bitmap words per slab {} exceeds u8 range", (u64)words);
        }
        slab->bitmap_words_per_slab = (u8)words;
        u32   idx       = slab_find_by_page(self, page_base);
        if (idx == (u32)-1) {
            LOG_FATAL("slab_free: foreign ptr {x} not in any slab", (u64)ptr);
            return 0;
        }
        // round it down and clear the wrong bit. Catch this explicitly.
        if ((offset & (self->slot_size - 1u)) != 0u) {
            LOG_FATAL("slab_free: misaligned ptr {x} (slot size {})", (u64)ptr, (u64)self->slot_size);
            return 0;
        }
        u64  mask = (u64)1 << bit;
        if (!(bm[w] & mask)) {
            LOG_FATAL("slab_free: double-free of {x} (slot {})", (u64)ptr, (u64)slot_idx);
            return 0;
        }
        ValidateBitVec(bv);
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
        ValidateBitVec(bitvec);
        if (idx >= bitvec->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bitvec->length);
        }
        u64 byte_idx   = BIT_INDEX(idx);
        ValidateBitVec(bitvec);
        if (idx >= bitvec->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bitvec->length);
        }
        u64 byte_idx   = BIT_INDEX(idx);
        ValidateBitVec(bitvec);
        if (idx >= bitvec->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bitvec->length);
        }
        u64 byte_idx   = BIT_INDEX(idx);
        ValidateBitVec(bitvec);
        if (bitvec->length == 0) {
            LOG_FATAL("Cannot pop from empty bitvector");
        }
        bool value = BitVecGet(bitvec, bitvec->length - 1);
        ValidateBitVec(bitvec);
        if (idx > bitvec->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bitvec->length);
        }
        if (!BitVecPush(bitvec, false)) {
        ValidateBitVec(bv);
        if (idx > bv->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bv->length);
        }
        if (count == 0) {
        ValidateBitVec(other);
        if (idx > bv->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bv->length);
        }
        if (other->length == 0) {
        ValidateBitVec(bv);
        if (idx > bv->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bv->length);
        }
        if (pattern_bits == 0 || pattern_bits > 8) {
        ValidateBitVec(bv);
        if (idx >= bv->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bv->length);
        }
        ValidateBitVec(bv);
        if (idx >= bv->length) {
            LOG_FATAL("Index {} exceeds bitvector length {}", idx, bv->length);
        }
        if (count == 0) {
    
        if (start1 + len > bv1->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector1 length {}", start1, LVAL(start1 + len - 1), bv1->length);
        }
        if (start2 + len > bv2->length) {
        }
        if (start2 + len > bv2->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector2 length {}", start2, LVAL(start2 + len - 1), bv2->length);
        }
    
        if (start1 + len > bv1->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector1 length {}", start1, LVAL(start1 + len - 1), bv1->length);
        }
        if (start2 + len > bv2->length) {
        }
        if (start2 + len > bv2->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector2 length {}", start2, LVAL(start2 + len - 1), bv2->length);
        }
        ValidateBitVec(bv);
        if (!out) {
            LOG_FATAL("out is NULL");
        }
    static bool bitvec_try_from_str_impl(BitVec *out, Zstr str, u64 str_len, Allocator *alloc) {
        if (!str) {
            LOG_FATAL("str is NULL");
        }
        if (!out) {
        }
        if (!out) {
            LOG_FATAL("out is NULL");
        }
    bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc) {
        if (!str) {
            LOG_FATAL("str is NULL");
        }
        return bitvec_try_from_str_impl(out, str, (u64)ZstrLen(str), alloc);
    bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc) {
        if (!str) {
            LOG_FATAL("str is NULL");
        }
        return bitvec_try_from_str_impl(out, str->data, str->length, alloc);
        ValidateBitVec(bv);
        if (!bytes) {
            LOG_FATAL("bytes is NULL");
        }
        if (max_len == 0) {
        }
        if (max_len == 0) {
            LOG_FATAL("max_len is 0");
        }
        if (bv->length == 0) {
    bool bitvec_try_from_bytes(BitVec *out, const u8 *bytes, u64 bit_len, Allocator *alloc) {
        if (!bytes) {
            LOG_FATAL("bytes is NULL");
        }
        if (!out) {
        }
        if (!out) {
            LOG_FATAL("out is NULL");
        }
    bool bitvec_try_from_integer(BitVec *out, u64 value, u64 bits, Allocator *alloc) {
        if (!out) {
            LOG_FATAL("out is NULL");
        }
    
        if (!results || max_results == 0) {
            LOG_FATAL("results is NULL or max_results is 0");
        }
    
        if (!out || !out->allocator) {
            LOG_FATAL("output BitVecMatchIndices is NULL or uninitialized");
        }
        ValidateBitVec(bv);
        if (!runs || !values || max_runs == 0) {
            LOG_FATAL("invalid arguments");
        }
        ValidateBitVec(bv);
        if (!out || !out->allocator) {
            LOG_FATAL("output BitVecRuns is NULL or uninitialized");
        }
        ValidateBitVec(bv2);
        if (!out) {
            LOG_FATAL("out is NULL");
        }
        ValidateBitVec(bv);
        if (!pattern) {
            LOG_FATAL("pattern is NULL");
        }
        ValidateBitVec(bv);
        if (!pattern) {
            LOG_FATAL("pattern is NULL");
        }
        ValidateBitVec(bv);
        if (!patterns) {
            LOG_FATAL("invalid BitVecs object provided");
        }
        ValidateBitVec(bv);
        if (!patterns) {
            LOG_FATAL("invalid arguments");
        }
    static void validate_bitvec_structural(const BitVec *bv) {
        if (bv->length > bv->capacity) {
            LOG_FATAL("Invalid bitvec object: length > capacity.");
        }
        if (bv->length > 0 && !bv->data) {
        }
        if (bv->length > 0 && !bv->data) {
            LOG_FATAL("Invalid bitvec object: length > 0 but data is NULL.");
        }
        if (bv->capacity > 0 && bv->byte_size * 8 < bv->capacity) {
        }
        if (bv->capacity > 0 && bv->byte_size * 8 < bv->capacity) {
            LOG_FATAL("Invalid bitvec object: byte_size too small for capacity.");
        }
        if (bv->data) {
    void ValidateBitVec(const BitVec *bv) {
        if (!bv) {
            LOG_FATAL("Invalid bitvec object: NULL.");
        }
        if (!MAGIC_MATCHES(bv->__magic, BITVEC_MAGIC)) {
        }
        if (!MAGIC_MATCHES(bv->__magic, BITVEC_MAGIC)) {
            LOG_FATAL("Invalid bitvec. Either uninitialized or corrupted!");
        }
        if (!(bv->__magic & MAGIC_VALIDATED_BIT)) {
    
        if (!alignment) {
            LOG_FATAL("Invalid graph allocator alignment. Did you initialize the graph before use?");
        }
    
        if ((alignment > 1) && !graph_alignment_is_pow2(alignment)) {
            LOG_FATAL("Graph allocator alignment must be 1 or a power of two");
        }
    }
    static void graph_validate_slot_limit(const GenericGraph *graph) {
        if (VecLen(&graph->slots) > (u64)UINT32_MAX) {
            LOG_FATAL("Graph exceeded maximum supported slot count");
        }
    }
    static void graph_validate_node_index_raw(const GenericGraph *graph, u32 index) {
        if ((u64)index >= VecLen(&graph->slots)) {
            LOG_FATAL("graph node id out of bounds");
        }
    }
    
        if (!generation) {
            LOG_FATAL("graph node id has invalid generation");
        }
    
        if (!graph_slot_is_occupied(slot)) {
            LOG_FATAL("graph node id refers to a free slot");
        }
    
        if (slot->generation != generation) {
            LOG_FATAL("graph node id is stale");
        }
    }
        graph = GENERIC_GRAPH(node._graph_);
        if (!graph) {
            LOG_FATAL("invalid graph node handle");
        }
    static void graph_ensure_slot_generation_available(GenericGraphSlot *slot) {
        if (slot->generation == UINT32_MAX) {
            LOG_FATAL("graph slot generation exhausted");
        }
    }
                1
            )) {
            LOG_FATAL("Graph failed to record a reusable slot index");
        }
    }
    
        if (!VecLen(&graph->free_indices)) {
            LOG_FATAL("expected at least one free graph slot");
        }
        in_idx       = graph_find_neighbor_index(in_neighbors, from);
        if (in_idx == SIZE_MAX) {
            LOG_FATAL("Graph reverse adjacency is inconsistent during edge removal");
        }
            } else {
                if (!graph_remove_edge_now(graph, from, neighbor_id)) {
                    LOG_FATAL("Graph failed to remove marked outgoing edge");
                }
                removed += 1;
            GraphNodeId to = VecLast(neighbors);
            if (!graph_remove_edge_now(graph, from, to)) {
                LOG_FATAL("Graph failed to remove outgoing edge during node deletion");
            }
            removed += 1;
    
        if (!graph) {
            LOG_FATAL("Expected a valid Graph pointer");
        }
    
        if (!MAGIC_MATCHES(graph->__magic, GRAPH_MAGIC)) {
            LOG_FATAL("Graph is uninitialized or corrupted");
        }
        // dereferencing the method table.
        if (!graph->allocator) {
            LOG_FATAL("Graph allocator pointer is NULL");
        }
        if (!graph->allocator->allocate || !graph->allocator->resize || !graph->allocator->remap ||
            !graph->allocator->deallocate) {
            LOG_FATAL("Graph allocator is not fully configured");
        }
    
        if (graph->live_count > VecLen(&graph->slots)) {
            LOG_FATAL("Graph live node count exceeds slot count");
        }
    
        if (graph->pending_delete_count > graph->live_count) {
            LOG_FATAL("Graph pending delete count exceeds live node count");
        }
    
        if ((graph->live_count + VecLen(&graph->free_indices)) != VecLen(&graph->slots)) {
            LOG_FATAL("Graph slot accounting is inconsistent");
        }
            if (graph_slot_is_occupied(slot)) {
                if (!slot->data) {
                    LOG_FATAL("Occupied graph slot has NULL payload");
                }
    
                if (!slot->generation) {
                    LOG_FATAL("Occupied graph slot has invalid generation");
                }
                    target_slot = graph_require_live_slot_const(graph, neighbor_id);
                    if (!graph_neighbors_contains(&target_slot->in_neighbors, self_id)) {
                        LOG_FATAL("Graph reverse adjacency is missing predecessor entry");
                    }
                }
                    source_slot = graph_require_live_slot_const(graph, predecessor_id);
                    if (!graph_neighbors_contains(&source_slot->out_neighbors, self_id)) {
                        LOG_FATAL("Graph reverse adjacency is missing outgoing edge");
                    }
                }
            } else {
                if (slot->data) {
                    LOG_FATAL("Free graph slot retains payload pointer");
                }
    
                if (slot->visit_count != 0) {
                    LOG_FATAL("Free graph slot retains visit count");
                }
    
                if (VecLen(&slot->out_neighbors) != 0) {
                    LOG_FATAL("Free graph slot retains outgoing edges");
                }
    
                if (VecLen(&slot->in_neighbors) != 0) {
                    LOG_FATAL("Free graph slot retains incoming edges");
                }
            }
            u32 index = VecAt(&graph->free_indices, free_index_i);
            if ((u64)index >= VecLen(&graph->slots)) {
                LOG_FATAL("Graph free slot index out of bounds");
            }
    
            if (graph_slot_is_occupied(VecPtrAt((GraphSlots *)&graph->slots, index))) {
                LOG_FATAL("Graph free index points to an occupied slot");
            }
        }
    
            if (!graph_neighbors_contains(neighbors, pending->to)) {
                LOG_FATAL("Graph pending edge removal refers to a missing edge");
            }
        }
    
        if (graph->live_count != live_count) {
            LOG_FATAL("Graph live node count is inconsistent");
        }
    
        if ((graph->edge_count != out_edge_count) || (graph->edge_count != in_edge_count)) {
            LOG_FATAL("Graph edge count is inconsistent");
        }
    
        if (graph->pending_delete_count != marked_count) {
            LOG_FATAL("Graph pending delete count is inconsistent");
        }
        // Mark verified.
    
        if (!graph || !item_data || !item_size) {
            LOG_FATAL("invalid arguments");
        }
            slot_ptr   = graph_slot_ptr_raw(graph, slot_index);
            if (graph_slot_is_occupied(slot_ptr)) {
                LOG_FATAL("graph free slot unexpectedly occupied");
            }
    
        if (!graph || !item_data || !item_size) {
            LOG_FATAL("invalid arguments");
        }
    
        if (!graph) {
            LOG_FATAL("invalid arguments");
        }
    
        if (GENERIC_GRAPH(validated._graph_) != graph) {
            LOG_FATAL("graph node handle does not belong to the provided graph");
        }
    
        if (neighbor_idx >= VecLen(neighbors)) {
            LOG_FATAL("graph neighbor index out of bounds");
        }
    
        if (predecessor_idx >= VecLen(neighbors)) {
            LOG_FATAL("graph predecessor index out of bounds");
        }
    
        if (slot->visit_count == UINT64_MAX) {
            LOG_FATAL("graph node visit count overflow");
        }
            if (graph_slot_is_occupied(slot) && graph_slot_is_marked(slot)) {
                if (VecLen(&slot->out_neighbors) || VecLen(&slot->in_neighbors)) {
                    LOG_FATAL("Graph marked node retained incident edges before release");
                }
                graph_release_slot(graph, slot, item_size);
    bool graph_node_iter_next(GenericGraphNodeIter *iter, GraphNode *out_node) {
        if (!iter || !out_node) {
            LOG_FATAL("invalid arguments");
        }
        ValidateGraph(iter->graph);
        if (iter->expected_mutation_epoch != iter->graph->mutation_epoch) {
            LOG_FATAL("graph structure changed during node iteration");
        }
    
        if (!iter || !out_node) {
            LOG_FATAL("invalid arguments");
        }
        ValidateGraph(iter->graph);
        if (iter->expected_mutation_epoch != iter->graph->mutation_epoch) {
            LOG_FATAL("graph structure changed during neighbor iteration");
        }
    
        if (!iter || !out_node) {
            LOG_FATAL("invalid arguments");
        }
        ValidateGraph(iter->graph);
        if (iter->expected_mutation_epoch != iter->graph->mutation_epoch) {
            LOG_FATAL("graph structure changed during predecessor iteration");
        }
    void deinit_list(GenericList *list, u64 item_size) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (!list || !item_size || !item_data) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (idx > list->length) {
            LOG_FATAL("list index out of range.");
        }
    void remove_range_list(GenericList *list, void *removed_data, u64 item_size, u64 start, u64 count) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
        // length would pass the bound check. Catch it first.
        if (count > UINT64_MAX - start) {
            LOG_FATAL("list remove range: start + count overflows u64");
        }
        if (start + count > list->length) {
        }
        if (start + count > list->length) {
            LOG_FATAL("List range out of bounds.");
        }
    
        if (!list || !item_size || !comp) {
            LOG_FATAL("invalid arguments.");
        }
        // would write past the buffer.
        if (item_size && item_count > UINT64_MAX / item_size) {
            LOG_FATAL("list_sort: item_size * item_count overflows u64");
        }
        data = AllocatorAlloc(list->allocator, item_size * item_count, false);
    void swap_list(GenericList *list, u64 item_size, u64 idx1, u64 idx2) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
        GenericListNode *n1 = node_at_list(list, item_size, idx1);
        if (!n1) {
            LOG_FATAL("failed to get node at specified index");
        }
        GenericListNode *n2 = node_at_list(list, item_size, idx2);
        if (!n2) {
            LOG_FATAL("failed to get node at specified index");
        }
    void reverse_list(GenericList *list, u64 item_size) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (!arr) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (!list1 || !item_size || !list2) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (list1 == list2) {
            LOG_FATAL("cannot merge list with itself.");
        }
    void clear_list(GenericList *list, u64 item_size) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
    GenericListNode *node_at_list(GenericList *list, u64 item_size, u64 idx) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (idx >= list->length) {
            LOG_FATAL("list index out of range.");
        }
    void *item_ptr_at_list(GenericList *list, u64 item_size, u64 idx) {
        if (!list || !item_size) {
            LOG_FATAL("invalid arguments.");
        }
    
        if (idx >= list->length) {
            LOG_FATAL("list index out of bounds.");
        }
    size find_idx_list(GenericList *list, const void *item_data, u64 item_size, GenericCompare comp) {
        if (!list || !item_data || !item_size || !comp) {
            LOG_FATAL("invalid arguments.");
        }
    static void validate_list_structural(const GenericList *l) {
        if (!l->allocator) {
            LOG_FATAL("List allocator pointer is NULL.");
        }
        if (!l->allocator->allocate || !l->allocator->resize || !l->allocator->remap || !l->allocator->deallocate) {
        }
        if (!l->allocator->allocate || !l->allocator->resize || !l->allocator->remap || !l->allocator->deallocate) {
            LOG_FATAL("Invalid list allocator.");
        }
        if (l->length == 0) {
        if (l->length == 0) {
            if (l->head || l->tail) {
                LOG_FATAL("Empty list must have NULL head and tail.");
            }
        } else {
        } else {
            if (!l->head) {
                LOG_FATAL("Non-empty list has NULL head.");
            }
            if (!l->tail) {
            }
            if (!l->tail) {
                LOG_FATAL("Non-empty list has NULL tail.");
            }
            if (l->head->prev) {
            }
            if (l->head->prev) {
                LOG_FATAL("List head must not have a previous node.");
            }
            if (l->tail->next) {
            }
            if (l->tail->next) {
                LOG_FATAL("List tail must not have a next node.");
            }
        }
    void validate_list(const GenericList *l) {
        if (!l) {
            LOG_FATAL("List pointer is NULL.");
        }
        if (!MAGIC_MATCHES(l->__magic, LIST_MAGIC)) {
        }
        if (!MAGIC_MATCHES(l->__magic, LIST_MAGIC)) {
            LOG_FATAL("Invalid list. Either not initialized or corrupted!");
        }
        if (!(l->__magic & MAGIC_VALIDATED_BIT)) {
    GenericListNode *get_node_relative_to_list_node(GenericListNode *node, i64 ridx) {
        if (!node) {
            LOG_FATAL("Invalid arguments");
        }
    GenericListNode *get_node_random_access(GenericList *list, GenericListNode *node, u64 nidx, i64 ridx) {
        if (!list || !node) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (nidx >= list->length) {
            LOG_FATAL("Node index exceeds list bounds");
        }
    
        if ((ridx < 0 && (u64)(-ridx) > nidx) || (ridx > 0 && nidx + (u64)ridx >= list->length)) {
            LOG_FATAL("Relative node index outside of list bounds");
        }
    GenericListNode *get_node_for_list_iteration(GenericList *list, GenericListNode *node, u64 nidx, u64 target_idx) {
        if (!list) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (target_idx >= list->length) {
            LOG_FATAL("Node index exceeds list bounds");
        }
    
        if (!items) {
            LOG_FATAL("Expected a valid pointer");
        }
        // ownership had moved out of the range it can still see.
        if (item_size && count > UINT64_MAX / item_size) {
            LOG_FATAL("list_insert_range_l: item_size * count overflows u64");
        }
    
        if (!items) {
            LOG_FATAL("Expected a valid pointer");
        }
        // real cause instead.
        if (!vec->allocator) {
            LOG_FATAL("vector not growable, no allocator assigned, probably stack inited");
        }
        if (n > vec->capacity) {
            if (!vec->allocator) {
                LOG_FATAL("vector not growable, no allocator assigned, probably stack inited");
            }
            size old_capacity = (size)vec->capacity;
        // allocator to free into / shrink through.
        if (!vec->allocator) {
            LOG_FATAL("vector not growable, no allocator assigned, probably stack inited");
        }
    
        if (idx > vec->length) {
            LOG_FATAL("vector index out of bounds, insertion at index greater than length");
        }
        // Overflow check on length + count. A wrapped sum below capacity
        // would skip the reserve and walk past the buffer.
        if (count > (size)-1 - vec->length) {
            LOG_FATAL("vector insert: length + count overflows size");
        }
    
        if (idx > vec->length) {
            LOG_FATAL("vector index out of bounds, insertion at index greater than length");
        }
        // Overflow check on length + count. Same shape as insert_range_into_vec.
        // Overflow check on length + count. Same shape as insert_range_into_vec.
        if (count > (size)-1 - vec->length) {
            LOG_FATAL("vector insert (fast): length + count overflows size");
        }
        // below length would pass the bound check. Catch it first.
        if (count > (size)-1 - start) {
            LOG_FATAL("vector remove range: start + count overflows size");
        }
        if (start + count > vec->length) {
        }
        if (start + count > vec->length) {
            LOG_FATAL("vector range out of bounds.");
        }
        // below length would pass the bound check. Catch it first.
        if (count > (size)-1 - start) {
            LOG_FATAL("vector fast remove range: start + count overflows size");
        }
        if (start + count > vec->length) {
        }
        if (start + count > vec->length) {
            LOG_FATAL("vector range out of bounds.");
        }
    
        if (vec_aligned_size(vec, item_size) != item_size) {
            LOG_FATAL(
                "QSort not implemented for vectors wherein the size of items don't "
                "match their aligned size."
    
        if (idx1 >= vec->length || idx2 >= vec->length) {
            LOG_FATAL("vector index out of bounds.");
        }
    
        if (!item_data || !comp) {
            LOG_FATAL("Invalid arguments.");
        }
    static void validate_vec_structural(const GenericVec *v) {
        if (v->length > v->capacity) {
            LOG_FATAL("Invalid vec object.");
        }
        if (v->allocator &&
        if (v->allocator &&
            (!v->allocator->allocate || !v->allocator->resize || !v->allocator->remap || !v->allocator->deallocate)) {
            LOG_FATAL("Invalid vec allocator.");
        }
        if (v->data) {
    void validate_vec(const GenericVec *v) {
        if (!v) {
            LOG_FATAL("NULL vec object pointer.");
        }
        if (!MAGIC_MATCHES(v->__magic, VEC_MAGIC)) {
        }
        if (!MAGIC_MATCHES(v->__magic, VEC_MAGIC)) {
            LOG_FATAL("Invalid vec object. Either uninitialized or corrupted!");
        }
        if (!(v->__magic & MAGIC_VALIDATED_BIT)) {
    
        if (!items) {
            LOG_FATAL("Expected a valid pointer");
        }
    bool vec_insert_range_r(GenericVec *vec, const void *items, size item_size, size idx, size count, bool preserve_order) {
        if (!items) {
            LOG_FATAL("Expected a valid pointer");
        }
    static i64 float_add_i64_checked(i64 a, i64 b) {
        if ((b > 0 && a > INT64_MAX - b) || (b < 0 && a < INT64_MIN - b)) {
            LOG_FATAL("Float exponent overflow");
        }
    static i64 float_sub_i64_checked(i64 a, i64 b) {
        if ((b > 0 && a < INT64_MIN + b) || (b < 0 && a > INT64_MAX + b)) {
            LOG_FATAL("Float exponent overflow");
        }
    static bool float_try_from_ieee_bits(Float *out, u64 mantissa, int binexp, bool negative, Allocator *alloc) {
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
        *out          = FloatInit(alloc);
    static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc) {
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
        union {
        u32  m    = bits & 0x7FFFFFu;
        if (e == 0xFFu) {
            LOG_FATAL("Float from f32 does not represent finite values (Inf/NaN)");
        }
        u64 mantissa;
    static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc) {
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
        union {
        u64  m    = bits & 0xFFFFFFFFFFFFFull;
        if (e == 0x7FFull) {
            LOG_FATAL("Float from f64 does not represent finite values (Inf/NaN)");
        }
        u64 mantissa;
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
        if (!int_try_from_u64(&base, 10, alloc) || !int_try_from_u64(&result, 1, alloc)) {
        }
        if (target_exponent > value->exponent) {
            LOG_FATAL("target exponent must not exceed current exponent");
        }
        if (target_exponent == value->exponent) {
        ValidateFloat(rhs);
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    bool FloatTryClone(Float *out, const Float *value) {
        if (!out || !value) {
            LOG_FATAL("Invalid arguments");
        }
    static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc) {
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    static bool float_try_from_int_value(Float *out, const Int *value) {
        if (!out || !value) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !text) {
            LOG_FATAL("Invalid arguments");
        }
    bool float_try_from_str_zstr(Float *out, Zstr text) {
        if (!out || !text) {
            LOG_FATAL("Invalid arguments");
        }
        return float_try_from_str_impl(out, text, (size)ZstrLen(text));
    bool float_try_from_str_str(Float *out, const Str *text) {
        if (!out || !text) {
            LOG_FATAL("Invalid arguments");
        }
        return float_try_from_str_impl(out, StrBegin(text), StrLen(text));
        ValidateFloat(value);
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    bool str_try_init_from_cstr(Str *out, Zstr cstr, size len, Allocator *alloc) {
        if (!out || !cstr) {
            LOG_FATAL("Invalid arguments");
        }
    bool StrInitCopy(Str *dst, const Str *src) {
        if (!dst || !src) {
            LOG_FATAL("Invalid arguments");
        }
        ValidateStr(src);
        if (!dst) {
            LOG_FATAL("Invalid arguments");
        }
    StrIters str_split_to_iters_str(Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
        }
        return str_split_to_iters_impl(s, key->data, key->length);
    Strs str_split_str(Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
        }
        return str_split_impl(s, key->data, key->length);
    
        if (!key) {
            LOG_FATAL("Invalid arguments");
        }
    size str_index_of_zstr(const Str *s, Zstr key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
        }
    size str_index_of_str(const Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
        }
    bool str_contains_str(const Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!value) {
            LOG_FATAL("NULL output pointer");
        }
    
        if (!value) {
            LOG_FATAL("NULL output pointer");
        }
    
        if (!value) {
            LOG_FATAL("NULL output pointer");
        }
    static size map_validate_policy_index(size idx, size capacity, Zstr callback_name) {
        if (capacity && idx >= capacity) {
            LOG_FATAL("{} returned index {} for capacity {}", callback_name, idx, capacity);
        }
    
        if (!policy) {
            LOG_FATAL("Expected a valid MapPolicy pointer");
        }
    
        if (!policy->name || !policy->name[0]) {
            LOG_FATAL("MapPolicy must have a non-empty name");
        }
    
        if (!policy->should_rehash || !policy->next_capacity || !policy->first_index || !policy->next_index) {
            LOG_FATAL("MapPolicy '{}' must provide all required callbacks", policy->name);
        }
    
        if (policy->max_probe_count == 0) {
            LOG_FATAL("MapPolicy '{}' must provide a non-zero max_probe_count", policy->name);
        }
    
            if ((next0 == 0) && ((length != 0) || (capacity != 0) || (tombstones != 0))) {
                LOG_FATAL("MapPolicy '{}' returned zero capacity for a non-empty snapshot", policy->name);
            }
    
            if ((next_same != 0) && (next_same < length)) {
                LOG_FATAL("MapPolicy '{}' returned capacity smaller than current length", policy->name);
            }
    
            if (next_more < ((size)length + 1)) {
                LOG_FATAL("MapPolicy '{}' returned capacity smaller than requested minimum entries", policy->name);
            }
        }
    
                if (next == first) {
                    LOG_FATAL("MapPolicy '{}' produced a stuck probe sequence for capacity {}", policy->name, capacity);
                }
            }
        limit = map->policy.max_probe_count;
        if (limit == 0) {
            LOG_FATAL("Map policy '{}' has invalid max_probe_count", map->policy.name);
        }
    static void validate_map_structural(const GenericMap *map) {
        if (!map->key_compare || !map->key_hash) {
            LOG_FATAL("Map must have valid key compare and key hash callbacks");
        }
        if (!map->allocator) {
        }
        if (!map->allocator) {
            LOG_FATAL("Map allocator pointer is NULL");
        }
        if (!map->allocator->allocate || !map->allocator->resize || !map->allocator->remap || !map->allocator->deallocate) {
        }
        if (!map->allocator->allocate || !map->allocator->resize || !map->allocator->remap || !map->allocator->deallocate) {
            LOG_FATAL("Map allocator is invalid");
        }
        validate_map_policy(&map->policy);
        validate_map_policy(&map->policy);
        if (map->length > map->capacity) {
            LOG_FATAL("Map length cannot exceed capacity");
        }
        if ((map->length + map->tombstones) > map->capacity) {
        }
        if ((map->length + map->tombstones) > map->capacity) {
            LOG_FATAL("Map occupied slots and tombstones cannot exceed capacity");
        }
        if (!map->capacity) {
        if (!map->capacity) {
            if (map->entries || map->states) {
                LOG_FATAL("Map with zero capacity must not have allocated storage");
            }
            return;
        }
        if (!map->entries || !map->states) {
            LOG_FATAL("Map storage is corrupted");
        }
    }
    void validate_map(const GenericMap *map) {
        if (!map) {
            LOG_FATAL("Expected a valid Map pointer");
        }
        if (!MAGIC_MATCHES(map->__magic, MAP_MAGIC)) {
        }
        if (!MAGIC_MATCHES(map->__magic, MAP_MAGIC)) {
            LOG_FATAL("Map is uninitialized or corrupted");
        }
        if (!(map->__magic & MAGIC_VALIDATED_BIT)) {
    
        if (new_capacity < (n > map->length ? n : (size)map->length)) {
            LOG_FATAL("Map policy '{}' returned insufficient capacity {}", policy.name, new_capacity);
        }
    
        if (!map->value_compare) {
            LOG_FATAL("MapContainsPair requires a value comparator");
        }
    
        if (!key || !default_value || !out_value) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (insert_idx >= map->capacity) {
            LOG_FATAL("map_insert: probe budget exhausted after 32 rehash attempts (capacity {})", map->capacity);
        }
    
        if (!map->value_compare) {
            LOG_FATAL("MapRemovePair requires a value comparator");
        }
    
        if (!predicate) {
            LOG_FATAL("MapRemoveIf requires a predicate");
        }
    
        if (!predicate) {
            LOG_FATAL("MapRetainIf requires a predicate");
        }
    static bool int_try_init_with_capacity(Int *out, u64 capacity, Allocator *alloc) {
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !digits) {
            LOG_FATAL("Invalid arguments");
        }
    bool IntTryLog2(const Int *value, u64 *out) {
        if (!value || !out) {
            LOG_FATAL("Invalid arguments");
        }
    static bool int_try_clone_value(Int *out, const Int *value) {
        if (!out || !value) {
            LOG_FATAL("Invalid arguments");
        }
    Int int_from_i64(i64 value, Allocator *alloc) {
        if (value < 0) {
            LOG_FATAL("Int cannot represent negative values");
        }
    bool IntTryToU64(const Int *value, u64 *out) {
        if (!value || !out) {
            LOG_FATAL("Invalid arguments");
        }
    Int int_from_bytes_le(const u8 *bytes, u64 len, Allocator *alloc) {
        if (!bytes && len != 0) {
            LOG_FATAL("bytes is NULL");
        }
    
        if (!bytes) {
            LOG_FATAL("bytes is NULL");
        }
        if (max_len == 0) {
        }
        if (max_len == 0) {
            LOG_FATAL("max_len is 0");
        }
    Int int_from_bytes_be(const u8 *bytes, u64 len, Allocator *alloc) {
        if (!bytes && len != 0) {
            LOG_FATAL("bytes is NULL");
        }
    
        if (!bytes) {
            LOG_FATAL("bytes is NULL");
        }
        if (max_len == 0) {
        }
        if (max_len == 0) {
            LOG_FATAL("max_len is 0");
        }
    
        if (!out || !decimal) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !decimal) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !digits) {
            LOG_FATAL("Invalid arguments");
        }
        len = (u64)ZstrLen(digits);
    
        if (!out || !digits) {
            LOG_FATAL("Invalid arguments");
        }
        if (StrLen(digits) > 0 && StrCharAt(digits, 0) == '+') {
        ValidateInt(value);
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !binary) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !binary) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !octal) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !octal) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!out || !hex) {
            LOG_FATAL("Invalid arguments");
        }
    bool int_try_from_hex_str_str(Int *out, const Str *hex) {
        if (!out || !hex) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (!int_sub_u64(result, value, magnitude)) {
            LOG_FATAL("int_add would produce a negative result");
        }
    bool int_mul_i64(Int *result, const Int *value, i64 factor) {
        if (factor < 0) {
            LOG_FATAL("Int cannot be multiplied by a negative scalar");
        }
    bool int_pow_i64(Int *result, const Int *base, i64 exponent) {
        if (exponent < 0) {
            LOG_FATAL("Int exponent cannot be negative");
        }
    
        if (quotient == remainder) {
            LOG_FATAL("quotient and remainder must be different objects");
        }
        if (IntIsZero(divisor)) {
    
        if (root == remainder) {
            LOG_FATAL("root and remainder must be different objects");
        }
        if (degree == 0) {
    
        if (!out) {
            LOG_FATAL("Invalid arguments");
        }
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
    bool int_pow_i64_mod(Int *result, const Int *base, i64 exponent, const Int *modulus) {
        if (exponent < 0) {
            LOG_FATAL("Int exponent cannot be negative");
        }
    Mutex *MutexLock(Mutex *m) {
        if (!m) {
            LOG_FATAL("MutexLock: NULL mutex");
        }
    #if PLATFORM_WINDOWS
    Mutex *MutexUnlock(Mutex *m) {
        if (!m) {
            LOG_FATAL("MutexUnlock: NULL mutex");
        }
    #if PLATFORM_WINDOWS
    bool symbol_resolver_init(SymbolResolver *out, Allocator *alloc) {
        if (!out || !alloc) {
            LOG_FATAL("SymbolResolverInit: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    bool socket_addr_parse_zstr(SocketAddr *out, Zstr spec, SocketKind kind) {
        if (!out) {
            LOG_FATAL("SocketAddrParse: out is NULL");
        }
        MemSet(out, 0, sizeof(*out));
    bool socket_addr_parse_str(SocketAddr *out, const Str *spec, SocketKind kind) {
        if (!out) {
            LOG_FATAL("SocketAddrParse: out is NULL");
        }
        MemSet(out, 0, sizeof(*out));
    bool ListenerOpen(Listener *out, SocketKind kind, const SocketAddr *addr, i32 backlog) {
        if (!out || !addr) {
            LOG_FATAL("ListenerOpen: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    bool ListenerLocalAddr(const Listener *self, SocketAddr *out) {
        if (!self || !out) {
            LOG_FATAL("ListenerLocalAddr: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    bool ListenerAccept(Listener *self, Socket *out_conn) {
        if (!self || !out_conn) {
            LOG_FATAL("ListenerAccept: NULL argument");
        }
        MemSet(out_conn, 0, sizeof(*out_conn));
    bool SocketConnect(Socket *out, SocketKind kind, const SocketAddr *target) {
        if (!out || !target) {
            LOG_FATAL("SocketConnect: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    i64 SocketRecv(Socket *self, void *buf, size n) {
        if (!self || !buf) {
            LOG_FATAL("SocketRecv: NULL argument");
        }
        return plat_recv(self->fd, buf, n);
    i64 SocketSend(Socket *self, const void *buf, size n) {
        if (!self || !buf) {
            LOG_FATAL("SocketSend: NULL argument");
        }
        return plat_send(self->fd, buf, n);
    i32 SocketPoll(SocketPollItem *items, u32 count, i32 timeout_ms) {
        if (!items && count > 0) {
            LOG_FATAL("SocketPoll: items is NULL but count > 0");
        }
    ProcStatus ProcWait(Proc *proc) {
        if (!proc) {
            LOG_FATAL("Invalid argument");
        }
    ProcStatus ProcWaitFor(Proc *proc, u64 timeout_ms) {
        if (!proc) {
            LOG_FATAL("Invalid arguments");
        }
    void ProcTerminate(Proc *proc) {
        if (!proc) {
            LOG_FATAL("Invalid argument");
        }
    i32 ProcWriteToStdin(Proc *proc, const Str *buf) {
        if (!proc || !buf) {
            LOG_FATAL("Invalid arguments");
        }
    static i32 proc_read_internal(Proc *proc, Str *buf, bool is_stdout) {
        if (!proc || !buf) {
            LOG_FATAL("Invalid argument");
        }
    i32 ProcGetId(Proc *proc) {
        if (!proc) {
            LOG_FATAL("Invalid argument");
        }
    ProcStatus ProcGetStatus(Proc *proc) {
        if (!proc) {
            LOG_FATAL("Invalid argument");
        }
    i32 ProcGetExitCode(Proc *proc) {
        if (!proc) {
            LOG_FATAL("Invalid argument");
        }
    bool proc_maps_load(ProcMaps *out, Allocator *alloc) {
        if (!out || !alloc) {
            LOG_FATAL("ProcMapsLoad: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    DirEntry *DirEntryInitCopy(DirEntry *dst, const DirEntry *src) {
        if (!dst || !src) {
            LOG_FATAL("Invalid arguments");
        }
    DirEntry *DirEntryDeinitCopy(DirEntry *copy) {
        if (!copy) {
            LOG_FATAL("Invalid arguments");
        }
    DirContents dir_get_contents(Zstr path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("Invalid argument");
        }
    DirContents dir_get_contents(Zstr path, Allocator *alloc) {
        if (!path || !alloc) {
            LOG_FATAL("Invalid arguments");
        }
    i8 file_remove(Zstr path) {
        if (!path) {
            LOG_FATAL("FileRemove: NULL path");
        }
    #if PLATFORM_WINDOWS
    i8 dir_remove(Zstr path) {
        if (!path) {
            LOG_FATAL("DirRemove: NULL path");
        }
    #if PLATFORM_WINDOWS
    i8 dir_create(Zstr path) {
        if (!path) {
            LOG_FATAL("DirCreate: NULL path");
        }
    #if PLATFORM_WINDOWS
    i8 dir_create_all(Zstr path) {
        if (!path) {
            LOG_FATAL("DirCreateAll: NULL path");
        }
        size n = ZstrLen(path);
    i8 dir_remove_all(Zstr path) {
        if (!path) {
            LOG_FATAL("DirRemoveAll: NULL path");
        }
        // Stat first: a missing path is a successful no-op (mirrors
    void HttpHeaderDeinit(HttpHeader *header) {
        if (!header) {
            LOG_FATAL("invalid arguments");
        }
        StrDeinit(&header->key);
    bool http_header_init_copy(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
        if (!dst_ptr || !src_ptr || !alloc) {
            LOG_FATAL("invalid arguments");
        }
        HttpHeader       *dst = (HttpHeader *)dst_ptr;
    HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key) {
        if (!headers || !key) {
            LOG_FATAL("invalid arguments");
        }
        VecForeachPtr(headers, header) {
    HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key) {
        if (!headers || !key) {
            LOG_FATAL("invalid arguments");
        }
        // Str values are NUL-terminated by construction; comparison scans
    Zstr http_request_parse_zstr(HttpRequest *req, Zstr in) {
        if (!req || !req->allocator || !in) {
            LOG_FATAL("invalid arguments");
        }
    Zstr http_request_parse_str(HttpRequest *req, const Str *in) {
        if (!req || !in) {
            LOG_FATAL("invalid arguments");
        }
        // Str values are NUL-terminated by construction; the underlying
    void HttpRequestDeinit(HttpRequest *req) {
        if (!req) {
            LOG_FATAL("invalid arguments");
        }
        StrDeinit(&req->url);
    HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html) {
        if (!response || !response->allocator || !html) {
            LOG_FATAL("invalid arguments");
        }
        response->status_code  = status;
    ) {
        if (!response || !response->allocator || !filepath) {
            LOG_FATAL("invalid arguments");
        }
        response->status_code  = status;
    ) {
        if (!filepath) {
            LOG_FATAL("invalid arguments");
        }
        return http_respond_with_file_zstr(response, status, content_type, (Zstr)StrBegin(filepath));
    
        if (!response) {
            LOG_FATAL("HttpResponseSerialize: response is NULL");
        }
    void HttpResponseDeinit(HttpResponse *response) {
        if (!response) {
            LOG_FATAL("invalid arguments");
        }
        StrDeinit(&response->body);
    static bool kvconfig_parse_bool_value(const Str *value, bool *out) {
        if (!out) {
            LOG_FATAL("Expected valid bool output pointer");
        }
    
        if (!out) {
            LOG_FATAL("Expected valid integer output pointer");
        }
    
        if (!out) {
            LOG_FATAL("Expected valid float output pointer");
        }
    
        if (!key) {
            LOG_FATAL("Expected valid key output string");
        }
    
        if (!value) {
            LOG_FATAL("Expected valid value output string");
        }
    
        if (!key || !value) {
            LOG_FATAL("Expected valid key/value outputs");
        }
    
        if (!cfg) {
            LOG_FATAL("Expected valid KvConfig object");
        }
    bool MachoOpenFromMemory(Macho *out, Buf *in) {
        if (!out || !in || !BufData(in) || !BufAllocator(in)) {
            LOG_FATAL("MachoOpenFromMemory: NULL argument (contract violation)");
        }
        Buf taken = *in;
    bool macho_open_from_memory_copy(Macho *out, const u8 *data, size data_size, Allocator *alloc) {
        if (!out || !data || !alloc) {
            LOG_FATAL("MachoOpenFromMemoryCopy: NULL argument (contract violation)");
        }
        Buf copy = BufInit(alloc);
    bool macho_open(Macho *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("MachoOpen: NULL argument (contract violation)");
        }
        Buf data = BufInit(alloc);
    
        if (!str) {
            LOG_FATAL("Invalid str object to read into.");
        }
    
        if (!num) {
            LOG_FATAL("Invalid number object.");
        }
    
        if (!val) {
            LOG_FATAL("Invalid pointer to integer. Don't know where to store.");
        }
    
        if (!val) {
            LOG_FATAL("Invalid pointer to float. Don't know where to store.");
        }
    
        if (!b) {
            LOG_FATAL("Invalid boolean pointer. Don't know where to store.");
        }
    
        if (!is_null) {
            LOG_FATAL("Invalid boolean pointer. Don't know where to store.");
        }
    bool ElfOpenFromMemory(Elf *out, Buf *in) {
        if (!out || !in || !BufData(in) || !BufAllocator(in)) {
            LOG_FATAL("ElfOpenFromMemory: NULL argument (contract violation)");
        }
        Buf taken = *in;
    bool elf_open_from_memory_copy(Elf *out, const u8 *data, size data_size, Allocator *alloc) {
        if (!out || !data || !alloc) {
            LOG_FATAL("ElfOpenFromMemoryCopy: NULL argument (contract violation)");
        }
        Buf copy = BufInit(alloc);
    bool elf_open(Elf *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("ElfOpen: NULL argument (contract violation)");
        }
        Buf data = BufInit(alloc);
    bool dwarf_lines_build_from_elf(DwarfLines *out, const Elf *elf, Allocator *alloc) {
        if (!out || !elf || !alloc) {
            LOG_FATAL("DwarfLinesBuildFromElf: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    ) {
        if (!out || !alloc) {
            LOG_FATAL("DwarfFunctionsBuildFromSlices: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    bool dwarf_functions_build_from_elf(DwarfFunctions *out, const Elf *elf, Allocator *alloc) {
        if (!out || !elf || !alloc) {
            LOG_FATAL("DwarfFunctionsBuildFromElf: NULL argument");
        }
        const ElfSection *info_sec   = ElfFindSection(elf, ".debug_info");
    bool PdbOpenFromMemory(Pdb *out, Buf *in) {
        if (!out || !in || !BufData(in) || !BufAllocator(in)) {
            LOG_FATAL("PdbOpenFromMemory: NULL argument (contract violation)");
        }
        Buf taken = *in;
    bool pdb_open_from_memory_copy(Pdb *out, const u8 *data, size data_size, Allocator *alloc) {
        if (!out || !data || !alloc) {
            LOG_FATAL("PdbOpenFromMemoryCopy: NULL argument (contract violation)");
        }
        Buf copy = BufInit(alloc);
    bool pdb_open(Pdb *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("PdbOpen: NULL argument (contract violation)");
        }
        Buf data = BufInit(alloc);
    bool dwarf_cfi_build_from_elf(DwarfCfi *out, const Elf *elf, Allocator *alloc) {
        if (!out || !elf || !alloc) {
            LOG_FATAL("DwarfCfiBuildFromElf: NULL argument");
        }
        MemSet(out, 0, sizeof(*out));
    bool PeOpenFromMemory(Pe *out, Buf *in) {
        if (!out || !in || !BufData(in) || !BufAllocator(in)) {
            LOG_FATAL("PeOpenFromMemory: NULL argument (contract violation)");
        }
        Buf taken = *in;
    bool pe_open_from_memory_copy(Pe *out, const u8 *data, size data_size, Allocator *alloc) {
        if (!out || !data || !alloc) {
            LOG_FATAL("PeOpenFromMemoryCopy: NULL argument (contract violation)");
        }
        Buf copy = BufInit(alloc);
    bool pe_open(Pe *out, Zstr path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_FATAL("PeOpen: NULL argument (contract violation)");
        }
        Buf data = BufInit(alloc);
    
        Node *p = (Node *)AllocatorAlloc(alloc1, sizeof(Node), false);
        AllocatorFree(alloc2, p); // foreign to bp2 -> LOG_FATAL
        return false;
    }
        // exposing it would invite misuse); the test needs a non-NULL
        // pointer in the bitmap region to exercise the foreign-ptr check.
        AllocatorFree(alloc, bp.bitmap); // bitmap region -> LOG_FATAL
        return false;
    }
        Allocator      *alloc     = ALLOCATOR_OF(&bp);
        char           *p         = (char *)AllocatorAlloc(alloc, sizeof(Node), false);
        AllocatorFree(alloc, p + 1); // mis-aligned -> LOG_FATAL
        return false;
    }
        Node           *p         = (Node *)AllocatorAlloc(alloc, sizeof(Node), false);
        AllocatorFree(alloc, p);
        AllocatorFree(alloc, p); // bit already 0 -> LOG_FATAL
        return false;
    }
        Allocator    *a2 = ALLOCATOR_OF(&s2);
        Node         *p  = (Node *)AllocatorAlloc(a1, sizeof(Node), false);
        AllocatorFree(a2, p); // foreign to s2 -> LOG_FATAL
        return false;
    }
        Allocator    *alloc = ALLOCATOR_OF(&slab);
        u8           *p     = (u8 *)AllocatorAlloc(alloc, sizeof(Node), false);
        AllocatorFree(alloc, p + 1); // mis-aligned -> LOG_FATAL
        return false;
    }
        Node         *p     = (Node *)AllocatorAlloc(alloc, sizeof(Node), false);
        AllocatorFree(alloc, p);
        AllocatorFree(alloc, p); // bit already 0 -> LOG_FATAL
        return false;
    }
        void *p = AllocatorAlloc(adbg, 32, true);
        AllocatorFree(adbg, p);
        AllocatorFree(adbg, p); // -> Heap LOG_FATAL
        return false;           // unreachable
    }
        Allocator    *alloc2 = ALLOCATOR_OF(&h2);
        void         *p      = AllocatorAlloc(alloc1, 32, false);
        AllocatorFree(alloc2, p); // foreign to h2 -> LOG_FATAL
        return false;             // unreachable
    }
        void         *p     = AllocatorAlloc(alloc, 32, false);
        AllocatorFree(alloc, p);
        AllocatorFree(alloc, p); // bit already 0 -> LOG_FATAL
        return false;
    }
        Allocator    *alloc = ALLOCATOR_OF(&heap);
        u8           *p     = (u8 *)AllocatorAlloc(alloc, 64, false);
        AllocatorFree(alloc, p + 1); // mis-aligned -> LOG_FATAL
        return false;
    }
        size          n     = 16 * 1024;
        u8           *p     = (u8 *)AllocatorAlloc(alloc, n, false);
        AllocatorFree(alloc, p + 128); // mid-allocation -> LOG_FATAL
        return false;
    }
        u8            *b          = (u8 *)AllocatorAlloc(alloc_base, 16, true);
        (void)b;
        (void)AllocatorRealloc(alloc_base, a, 64); // -> LOG_FATAL
        return false;                              // unreachable
    }
        Allocator     *alloc_base = ALLOCATOR_OF(&arena);
        char           stack_byte = 0;
        AllocatorFree(alloc_base, &stack_byte); // -> LOG_FATAL
        return false;                           // unreachable
    }
        BitVecPush(&pattern, true);
    
        BitVecFindPattern(NULL, &pattern); // Should cause LOG_FATAL
    
        BitVecDeinit(&pattern);
        BitVecPush(&source, false);
    
        BitVecFindPattern(&source, NULL); // Should cause LOG_FATAL
    
        BitVecDeinit(&source);
        BitVecPush(&pattern, true);
    
        BitVecFindLastPattern(NULL, &pattern); // Should cause LOG_FATAL
    
        BitVecDeinit(&pattern);
        BitVecPush(&source, false);
    
        BitVecFindLastPattern(&source, NULL); // Should cause LOG_FATAL
    
        BitVecDeinit(&source);
    
        // Don't create pattern BitVec since we're testing NULL source validation
        BitVecFindAllPattern(NULL, (BitVec *)0x1, results, 10); // Should cause LOG_FATAL
    
        return true;
        BitVecPush(&source, false);
    
        BitVecFindAllPattern(&source, NULL, results, 10); // Should cause LOG_FATAL
    
        BitVecDeinit(&source);
        BitVecPush(&pattern, true);
    
        BitVecFindAllPattern(&source, &pattern, NULL, 10); // Should cause LOG_FATAL
    
        BitVecDeinit(&source);
        BitVecPush(&pattern, true);
    
        BitVecFindAllPattern(&source, &pattern, results, 0); // Should cause LOG_FATAL
    
        BitVecDeinit(&source);
        do {                                                                                                               \
            if (!IterRead((mi), (out))) {                                                                                  \
                LOG_FATAL("IterMustRead: iterator exhausted");                                                             \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!IterPeekAt((mi), (n), (out))) {                                                                           \
                LOG_FATAL("IterMustPeekAt: offset out of range");                                                          \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!IterMove((mi), (n))) {                                                                                    \
                LOG_FATAL("IterMustMove: target position out of range");                                                   \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!GraphAddNodeL((g), (lval))) {                                                                             \
                LOG_FATAL("GraphMustAddNodeL failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!GraphAddNodeR((g), (rval))) {                                                                             \
                LOG_FATAL("GraphMustAddNodeR failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!GraphAddEdge((g), (from), (to))) {                                                                        \
                LOG_FATAL("GraphMustAddEdge failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!GraphReserve((g), (n))) {                                                                                 \
                LOG_FATAL("GraphMustReserve failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListSort((l), (compare))) {                                                                               \
                LOG_FATAL("ListMustSort failed");                                                                          \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListInsertL((l), (lval), (idx))) {                                                                        \
                LOG_FATAL("ListMustInsertL failed");                                                                       \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListInsertR((l), (rval), (idx))) {                                                                        \
                LOG_FATAL("ListMustInsertR failed");                                                                       \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListInsert((l), (lval), (idx))) {                                                                         \
                LOG_FATAL("ListMustInsert failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushFrontL((l), (lval))) {                                                                            \
                LOG_FATAL("ListMustPushFrontL failed");                                                                    \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushFrontR((l), (rval))) {                                                                            \
                LOG_FATAL("ListMustPushFrontR failed");                                                                    \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushFront((l), (lval))) {                                                                             \
                LOG_FATAL("ListMustPushFront failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushBackL((l), (lval))) {                                                                             \
                LOG_FATAL("ListMustPushBackL failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushBackR((l), (rval))) {                                                                             \
                LOG_FATAL("ListMustPushBackR failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushBack((l), (lval))) {                                                                              \
                LOG_FATAL("ListMustPushBack failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushArrL((l), (arr), (count))) {                                                                      \
                LOG_FATAL("ListMustPushArrL failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushArrR((l), (arr), (count))) {                                                                      \
                LOG_FATAL("ListMustPushArrR failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListPushArr((l), (arr), (count))) {                                                                       \
                LOG_FATAL("ListMustPushArr failed");                                                                       \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListMergeL((l), (l2))) {                                                                                  \
                LOG_FATAL("ListMustMergeL failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListMergeR((l), (l2))) {                                                                                  \
                LOG_FATAL("ListMustMergeR failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!ListMerge((l), (l2))) {                                                                                   \
                LOG_FATAL("ListMustMerge failed");                                                                         \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertL((v), (lval), (idx))) {                                                                         \
                LOG_FATAL("VecMustInsertL failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertR((v), (rval), (idx))) {                                                                         \
                LOG_FATAL("VecMustInsertR failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsert((v), (lval), (idx))) {                                                                          \
                LOG_FATAL("VecMustInsert failed");                                                                         \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertFastL((v), (lval), (idx))) {                                                                     \
                LOG_FATAL("VecMustInsertFastL failed");                                                                    \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertFastR((v), (rval), (idx))) {                                                                     \
                LOG_FATAL("VecMustInsertFastR failed");                                                                    \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertFast((v), (lval), (idx))) {                                                                      \
                LOG_FATAL("VecMustInsertFast failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertRangeL((v), (varr), (idx), (count))) {                                                           \
                LOG_FATAL("VecMustInsertRangeL failed");                                                                   \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertRangeR((v), (varr), (idx), (count))) {                                                           \
                LOG_FATAL("VecMustInsertRangeR failed");                                                                   \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertRange((v), (varr), (idx), (count))) {                                                            \
                LOG_FATAL("VecMustInsertRange failed");                                                                    \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertRangeFastL((v), (varr), (idx), (count))) {                                                       \
                LOG_FATAL("VecMustInsertRangeFastL failed");                                                               \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertRangeFastR((v), (varr), (idx), (count))) {                                                       \
                LOG_FATAL("VecMustInsertRangeFastR failed");                                                               \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInsertRangeFast((v), (varr), (idx), (count))) {                                                        \
                LOG_FATAL("VecMustInsertRangeFast failed");                                                                \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushBackArrL((v), (arr), (count))) {                                                                   \
                LOG_FATAL("VecMustPushBackArrL failed");                                                                   \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushBackArrR((v), (arr), (count))) {                                                                   \
                LOG_FATAL("VecMustPushBackArrR failed");                                                                   \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushBackArr((v), (arr), (count))) {                                                                    \
                LOG_FATAL("VecMustPushBackArr failed");                                                                    \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontArrL((v), (arr), (count))) {                                                                  \
                LOG_FATAL("VecMustPushFrontArrL failed");                                                                  \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontArrR((v), (arr), (count))) {                                                                  \
                LOG_FATAL("VecMustPushFrontArrR failed");                                                                  \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontArr((v), (arr), (count))) {                                                                   \
                LOG_FATAL("VecMustPushFrontArr failed");                                                                   \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontArrFastL((v), (arr), (count))) {                                                              \
                LOG_FATAL("VecMustPushFrontArrFastL failed");                                                              \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontArrFastR((v), (arr), (count))) {                                                              \
                LOG_FATAL("VecMustPushFrontArrFastR failed");                                                              \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontArrFast((v), (arr), (count))) {                                                               \
                LOG_FATAL("VecMustPushFrontArrFast failed");                                                               \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecMergeL((v), (v2))) {                                                                                   \
                LOG_FATAL("VecMustMergeL failed");                                                                         \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecMergeR((v), (v2))) {                                                                                   \
                LOG_FATAL("VecMustMergeR failed");                                                                         \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecMerge((v), (v2))) {                                                                                    \
                LOG_FATAL("VecMustMerge failed");                                                                          \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushBackL((v), (val))) {                                                                               \
                LOG_FATAL("VecMustPushBackL failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushBackR((v), (val))) {                                                                               \
                LOG_FATAL("VecMustPushBackR failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushBack((v), (val))) {                                                                                \
                LOG_FATAL("VecMustPushBack failed");                                                                       \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontL((v), (val))) {                                                                              \
                LOG_FATAL("VecMustPushFrontL failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFrontR((v), (val))) {                                                                              \
                LOG_FATAL("VecMustPushFrontR failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecPushFront((v), (val))) {                                                                               \
                LOG_FATAL("VecMustPushFront failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecInitClone((vd), (vs))) {                                                                               \
                LOG_FATAL("VecMustInitClone failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecTryReduceSpace((v))) {                                                                                 \
                LOG_FATAL("VecTryReduceSpace failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecResize((v), (len))) {                                                                                  \
                LOG_FATAL("VecResize failed");                                                                             \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!VecReserve((v), (n))) {                                                                                   \
                LOG_FATAL("VecReserve failed");                                                                            \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecReserve((bv), (n))) {                                                                               \
                LOG_FATAL("BitVecMustReserve failed");                                                                     \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecResize((bv), (n))) {                                                                                \
                LOG_FATAL("BitVecMustResize failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecInsertRange((bv), (idx), (count), (value))) {                                                       \
                LOG_FATAL("BitVecMustInsertRange failed");                                                                 \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecInsertMultiple((bv), (idx), (other))) {                                                             \
                LOG_FATAL("BitVecMustInsertMultiple failed");                                                              \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecInsertPattern((bv), (idx), (pattern), (pattern_bits))) {                                            \
                LOG_FATAL("BitVecMustInsertPattern failed");                                                               \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecPush((bv), (value))) {                                                                              \
                LOG_FATAL("BitVecMustPush failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!BitVecInsert((bv), (idx), (value))) {                                                                     \
                LOG_FATAL("BitVecMustInsert failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapInsertL((m), (in_key), (in_value))) {                                                                  \
                LOG_FATAL("MapMustInsertL failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapInsertR((m), (in_key), (in_value))) {                                                                  \
                LOG_FATAL("MapMustInsertR failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapInsert((m), (in_key), (in_value))) {                                                                   \
                LOG_FATAL("MapMustInsert failed");                                                                         \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapSetFirstL((m), (in_key), (in_value))) {                                                                \
                LOG_FATAL("MapMustSetFirstL failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapSetFirstR((m), (in_key), (in_value))) {                                                                \
                LOG_FATAL("MapMustSetFirstR failed");                                                                      \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapSetOnlyL((m), (in_key), (in_value))) {                                                                 \
                LOG_FATAL("MapMustSetOnlyL failed");                                                                       \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapSetOnlyR((m), (in_key), (in_value))) {                                                                 \
                LOG_FATAL("MapMustSetOnlyR failed");                                                                       \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapSet((m), (in_key), (in_value))) {                                                                      \
                LOG_FATAL("MapMustSet failed");                                                                            \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapReserve((m), (n))) {                                                                                   \
                LOG_FATAL("MapMustReserve failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapCompact((m))) {                                                                                        \
                LOG_FATAL("MapMustCompact failed");                                                                        \
            }                                                                                                              \
        } while (0)
        do {                                                                                                               \
            if (!MapRehashWithPolicy((m), (n), (policy_value))) {                                                          \
                LOG_FATAL("MapMustRehashWithPolicy failed");                                                               \
            }                                                                                                              \
        } while (0)
Last updated on