ALLOCATOR_OF
Description
Convert any allocator pointer to Allocator *. The argument may be:
- a typed allocator pointer (
HeapAllocator *,PageAllocator *,
ArenaAllocator *, SlabAllocator *, BudgetAllocator *, DebugAllocator *), in which case the macro typecasts the whole pointer to Allocator *. The cast is safe because every typed allocator carries Allocator base at offset zero — the C-style inheritance contract.
- a raw
Allocator *, which is returned unchanged.
Any other pointer type triggers a _Generic mismatch at compile time, which is the type-safety check the macro layer provides.
Callers do not write &heap.base or (Allocator *)&heap by hand — every macro that takes an allocator pointer routes it through this macro first.
Usage example (from documentation)
HeapAllocator heap = HeapAllocatorInit();
Vec(int) v = VecInit(&heap); // macro internally does ALLOCATOR_OF(&heap)
void library_helper(Vec *v, Allocator *alloc) {
Vec(int) scratch = VecInit(alloc); // raw Allocator* also accepted
}
Adding a new typed allocator requires adding it to this whitelist
(and forward-declaring it above).
Note for new code: the conventions doc (CODING-CONVENTIONS.md,
"_Generic dispatch") asks each macro to inline its own _Generic
instead of going through a shared "convert type X to Y" helper.
`ALLOCATOR_OF` is the project-wide exception: it's the single
canonical erasure point used by every container init macro and
every parser/sys backend that needs to take an `Allocator *`
from a typed-allocator handle. Folding it inline at every
call site would explode the dispatch surface; keeping the
shared name makes the type-erasure step searchable.Success
Expands to an Allocator * referring to the same instance.
Failure
Compile-time _Generic mismatch on any pointer type that is not Allocator * or one of the listed typed allocator pointers.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Zstr.h:170:
#define ZstrDupN(...) OVERLOAD(ZstrDupN, __VA_ARGS__)
#define ZstrDupN_2(src, n) zstr_dup_n((src), (n), MisraScope)
#define ZstrDupN_3(src, n, alloc) zstr_dup_n((src), (n), ALLOCATOR_OF(alloc))
///
- In
Zstr.h:184:
#define ZstrDup(...) OVERLOAD(ZstrDup, __VA_ARGS__)
#define ZstrDup_1(src) zstr_dup((src), MisraScope)
#define ZstrDup_2(src, alloc) zstr_dup((src), ALLOCATOR_OF(alloc))
///
- In
ArgParse.h:166:
(( \
ArgParse \
) {.alloc = ALLOCATOR_OF(alloc_ptr), .name = (prog_name), .about = (prog_about), .specs = VecInit_1(alloc_ptr)})
///
- In
File.h:360:
#define FileOpenTemp(...) OVERLOAD(FileOpenTemp, __VA_ARGS__)
#define FileOpenTemp_1(out_path) file_open_temp((out_path), MisraScope)
#define FileOpenTemp_2(out_path, alloc) file_open_temp((out_path), ALLOCATOR_OF(alloc))
#endif // MISRA_STD_FILE_H
- In
Allocator.h:174:
/// TAGS: Allocator, Stats, Accessor
///
# define AllocatorBytesRequested(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_requested)
# define AllocatorBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_in_use)
# define AllocatorPeakBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.peak_bytes_in_use)- In
Allocator.h:175:
///
# define AllocatorBytesRequested(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_requested)
# define AllocatorBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_in_use)
# define AllocatorPeakBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.peak_bytes_in_use)
# define AllocatorAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.allocations)- In
Allocator.h:176:
# define AllocatorBytesRequested(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_requested)
# define AllocatorBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_in_use)
# define AllocatorPeakBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.peak_bytes_in_use)
# define AllocatorAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.allocations)
# define AllocatorReallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.reallocations)- In
Allocator.h:177:
# define AllocatorBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.bytes_in_use)
# define AllocatorPeakBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.peak_bytes_in_use)
# define AllocatorAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.allocations)
# define AllocatorReallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.reallocations)
# define AllocatorDeallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.deallocations)- In
Allocator.h:178:
# define AllocatorPeakBytesInUse(a) ((void)0, ALLOCATOR_OF(a)->stats.peak_bytes_in_use)
# define AllocatorAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.allocations)
# define AllocatorReallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.reallocations)
# define AllocatorDeallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.deallocations)
# define AllocatorFailedAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.failed_allocations)- In
Allocator.h:179:
# define AllocatorAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.allocations)
# define AllocatorReallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.reallocations)
# define AllocatorDeallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.deallocations)
# define AllocatorFailedAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.failed_allocations)- In
Allocator.h:180:
# define AllocatorReallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.reallocations)
# define AllocatorDeallocations(a) ((void)0, ALLOCATOR_OF(a)->stats.deallocations)
# define AllocatorFailedAllocations(a) ((void)0, ALLOCATOR_OF(a)->stats.failed_allocations)
///
- In
Allocator.h:546:
/// TAGS: Allocator, Memory, Observability
///
#define AllocatorFootprintBytes(a) ((void)0, ALLOCATOR_OF(a)->footprint_bytes)
///
- In
Allocator.h:562:
/// TAGS: Allocator, Alignment, Accessor
///
#define AllocatorAlignment(a) ((void)0, ALLOCATOR_OF(a)->alignment)
// Typed allocator headers (PageAllocator, HeapAllocator, ArenaAllocator,
- In
Io.h:400:
float_try_to_decimal_str((out), (value), (precision), (has_precision), MisraScope)
# define FloatTryToDecimalStr_5(out, value, precision, has_precision, alloc) \
float_try_to_decimal_str((out), (value), (precision), (has_precision), ALLOCATOR_OF(alloc))
///
- In
Io.h:432:
float_try_to_scientific_str((out), (value), (precision), (has_precision), (uppercase), MisraScope)
# define FloatTryToScientificStr_6(out, value, precision, has_precision, uppercase, alloc) \
float_try_to_scientific_str((out), (value), (precision), (has_precision), (uppercase), ALLOCATOR_OF(alloc))
#endif // FEATURE_FLOAT
- In
Init.h:86:
.pending_delete_count = 0, \
.mutation_epoch = 0, \
.allocator = ALLOCATOR_OF(typed_alloc_ptr), \
.__magic = GRAPH_MAGIC | MAGIC_VALIDATED_BIT}- In
Convert.h:45:
_Generic((value), Int *: float_from_int, unsigned char: float_from_u64, unsigned short: float_from_u64, unsigned int: float_from_u64, unsigned long: float_from_u64, unsigned long long: float_from_u64, signed char: float_from_i64, signed short: float_from_i64, signed int: float_from_i64, signed long: float_from_i64, signed long long: float_from_i64, float: float_from_f32, double: float_from_f64)( \
(value), \
ALLOCATOR_OF(allocator_ptr) \
)
#endif- In
Convert.h:115:
_Generic((text), Str *: float_from_str_str, Zstr: float_from_str_zstr, char *: float_from_str_zstr)( \
(text), \
ALLOCATOR_OF(alloc) \
)- In
Init.h:45:
.copy_deinit = NULL, \
.data = NULL, \
.allocator = ALLOCATOR_OF(allocator_ptr), \
.__magic = VEC_MAGIC | MAGIC_VALIDATED_BIT}- In
Init.h:81:
.copy_deinit = (GenericCopyDeinit)(cd), \
.data = NULL, \
.allocator = ALLOCATOR_OF(allocator_ptr), \
.__magic = VEC_MAGIC | MAGIC_VALIDATED_BIT}- In
Convert.h:71:
(out), \
(str), \
ALLOCATOR_OF(alloc) \
)- In
Convert.h:96:
_Generic((str), Str *: bitvec_from_str_str, Zstr: bitvec_from_str_zstr, char *: bitvec_from_str_zstr)( \
(str), \
ALLOCATOR_OF(alloc) \
)- In
Convert.h:138:
#define BitVecTryFromBytes_3(out, bytes, bit_len) bitvec_try_from_bytes((out), (bytes), (bit_len), MisraScope)
#define BitVecTryFromBytes_4(out, bytes, bit_len, alloc) \
bitvec_try_from_bytes((out), (bytes), (bit_len), ALLOCATOR_OF(alloc))
///
- In
Convert.h:155:
#define BitVecFromBytes(...) OVERLOAD(BitVecFromBytes, __VA_ARGS__)
#define BitVecFromBytes_2(bytes, bit_len) bitvec_from_bytes((bytes), (bit_len), MisraScope)
#define BitVecFromBytes_3(bytes, bit_len, alloc) bitvec_from_bytes((bytes), (bit_len), ALLOCATOR_OF(alloc))
///
- In
Convert.h:193:
#define BitVecTryFromInteger_3(out, value, bits) bitvec_try_from_integer((out), (value), (bits), MisraScope)
#define BitVecTryFromInteger_4(out, value, bits, alloc) \
bitvec_try_from_integer((out), (value), (bits), ALLOCATOR_OF(alloc))
///
- In
Convert.h:210:
#define BitVecFromInteger(...) OVERLOAD(BitVecFromInteger, __VA_ARGS__)
#define BitVecFromInteger_2(value, bits) bitvec_from_integer((value), (bits), MisraScope)
#define BitVecFromInteger_3(value, bits, alloc) bitvec_from_integer((value), (bits), ALLOCATOR_OF(alloc))
#ifdef __cplusplus- In
Init.h:71:
.data = NULL, \
.byte_size = 0, \
.allocator = ALLOCATOR_OF(allocator_ptr), \
.__magic = BITVEC_MAGIC | MAGIC_VALIDATED_BIT \
})- In
Init.h:80:
.data = NULL, \
.byte_size = 0, \
.allocator = ALLOCATOR_OF(allocator_ptr), \
.__magic = BITVEC_MAGIC | MAGIC_VALIDATED_BIT})
#endif- In
Init.h:100:
#define BitVecInitWithCapacity(...) OVERLOAD(BitVecInitWithCapacity, __VA_ARGS__)
#define BitVecInitWithCapacity_1(cap) bitvec_init_with_capacity((cap), MisraScope)
#define BitVecInitWithCapacity_2(cap, alloc) bitvec_init_with_capacity((cap), ALLOCATOR_OF(alloc))
///
- In
Convert.h:41:
_Generic((value), unsigned char: int_from_u64, unsigned short: int_from_u64, unsigned int: int_from_u64, unsigned long: int_from_u64, unsigned long long: int_from_u64, signed char: int_from_i64, signed short: int_from_i64, signed int: int_from_i64, signed long: int_from_i64, signed long long: int_from_i64)( \
(value), \
ALLOCATOR_OF(alloc) \
)
#endif- In
Convert.h:95:
#define IntFromBytesLE(...) OVERLOAD(IntFromBytesLE, __VA_ARGS__)
#define IntFromBytesLE_2(bytes, len) int_from_bytes_le((bytes), (len), MisraScope)
#define IntFromBytesLE_3(bytes, len, alloc) int_from_bytes_le((bytes), (len), ALLOCATOR_OF(alloc))
///
- In
Convert.h:139:
#define IntFromBytesBE(...) OVERLOAD(IntFromBytesBE, __VA_ARGS__)
#define IntFromBytesBE_2(bytes, len) int_from_bytes_be((bytes), (len), MisraScope)
#define IntFromBytesBE_3(bytes, len, alloc) int_from_bytes_be((bytes), (len), ALLOCATOR_OF(alloc))
///
- In
Convert.h:215:
(digits), \
(radix), \
ALLOCATOR_OF(alloc) \
)- In
Convert.h:288:
_Generic((decimal), Str *: int_from_str_str, Zstr: int_from_str_zstr, char *: int_from_str_zstr)( \
(decimal), \
ALLOCATOR_OF(alloc) \
)- In
Convert.h:359:
_Generic((binary), Str *: int_from_binary_str, Zstr: int_from_binary_zstr, char *: int_from_binary_zstr)( \
(binary), \
ALLOCATOR_OF(alloc) \
)- In
Convert.h:430:
_Generic((octal), Str *: int_from_oct_str_str, Zstr: int_from_oct_str_zstr, char *: int_from_oct_str_zstr)( \
(octal), \
ALLOCATOR_OF(alloc) \
)- In
Convert.h:503:
_Generic((hex), Str *: int_from_hex_str_str, Zstr: int_from_hex_str_zstr, char *: int_from_hex_str_zstr)( \
(hex), \
ALLOCATOR_OF(alloc) \
)- In
Init.h:76:
///
#define StrTryInitFromCstr(out, cstr, len, allocator_ptr) \
str_try_init_from_cstr((out), (cstr), (len), ALLOCATOR_OF(allocator_ptr))
///
- In
Init.h:93:
#define StrInitFromCstr(...) OVERLOAD(StrInitFromCstr, __VA_ARGS__)
#define StrInitFromCstr_2(cstr, len) str_init_from_cstr((cstr), (len), MisraScope)
#define StrInitFromCstr_3(cstr, len, alloc) str_init_from_cstr((cstr), (len), ALLOCATOR_OF(alloc))
///
- In
Init.h:45:
.copy_deinit = (GenericCopyDeinit)(cd), \
.length = 0, \
.allocator = ALLOCATOR_OF(typed_alloc_ptr), \
.__magic = LIST_MAGIC | MAGIC_VALIDATED_BIT}- In
Init.h:44:
.states = NULL, \
.policy = validate_map_policy_copy((policy_value)), \
.allocator = ALLOCATOR_OF(typed_alloc_ptr), \
.__magic = MAP_MAGIC | MAGIC_VALIDATED_BIT}- In
Socket.h:184:
#define SocketAddrFormat(...) OVERLOAD(SocketAddrFormat, __VA_ARGS__)
#define SocketAddrFormat_1(addr) socket_addr_format((addr), MisraScope)
#define SocketAddrFormat_2(addr, alloc) socket_addr_format((addr), ALLOCATOR_OF(alloc))
// --- Listener (server side) -------------------------------------------------
- In
Dir.h:126:
_Generic( \
(path), \
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Dir.h:127:
(path), \
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Dir.h:128:
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
PdbCache.h:62:
#define PdbCacheInit(...) OVERLOAD(PdbCacheInit, __VA_ARGS__)
#define PdbCacheInit_0() PdbCacheInit_1(MisraScope)
#define PdbCacheInit_1(alloc_ptr) ((PdbCache) {.allocator = ALLOCATOR_OF(alloc_ptr), .entries = VecInit_1(alloc_ptr)})
///
- In
Proc.h:102:
#define ProcInit(...) OVERLOAD(ProcInit, __VA_ARGS__)
#define ProcInit_3(path, argv, envp) proc_init((path), (argv), (envp), MisraScope)
#define ProcInit_4(path, argv, envp, alloc) proc_init((path), (argv), (envp), ALLOCATOR_OF(alloc))
///
#define SymbolResolverInit(...) OVERLOAD(SymbolResolverInit, __VA_ARGS__)
#define SymbolResolverInit_1(out) symbol_resolver_init((out), MisraScope)
#define SymbolResolverInit_2(out, alloc) symbol_resolver_init((out), ALLOCATOR_OF(alloc))
///
- In
Dns.h:86:
#define DnsResolverInit(...) OVERLOAD(DnsResolverInit, __VA_ARGS__)
#define DnsResolverInit_1(out) dns_resolver_init((out), MisraScope)
#define DnsResolverInit_2(out, alloc) dns_resolver_init((out), ALLOCATOR_OF(alloc))
///
- In
MachoCache.h:65:
#define MachoCacheInit(...) OVERLOAD(MachoCacheInit, __VA_ARGS__)
#define MachoCacheInit_0() MachoCacheInit_1(MisraScope)
#define MachoCacheInit_1(alloc_ptr) ((MachoCache) {.allocator = ALLOCATOR_OF(alloc_ptr), .entries = VecInit_1(alloc_ptr)})
///
- In
Http.h:247:
#define HttpRequestInit_0() HttpRequestInit_1(MisraScope)
#define HttpRequestInit_1(alloc_ptr) \
((HttpRequest) {.allocator = ALLOCATOR_OF(alloc_ptr), \
.method = HTTP_REQUEST_METHOD_UNKNOWN, \
.url = StrInit_1(alloc_ptr), \- In
Http.h:312:
#define HttpResponseInit_0() HttpResponseInit_1(MisraScope)
#define HttpResponseInit_1(alloc_ptr) \
((HttpResponse) {.allocator = ALLOCATOR_OF(alloc_ptr), \
.content_type = HTTP_CONTENT_TYPE_INVALID, \
.status_code = HTTP_RESPONSE_CODE_INVALID, \- In
Http.h:378:
#define HttpResponseSerialize(...) OVERLOAD(HttpResponseSerialize, __VA_ARGS__)
#define HttpResponseSerialize_1(response) http_response_serialize((response), MisraScope)
#define HttpResponseSerialize_2(response, alloc) http_response_serialize((response), ALLOCATOR_OF(alloc))
///
- In
Pdb.h:141:
_Generic( \
(path), \
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Pdb.h:142:
(path), \
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pdb.h:143:
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pdb.h:184:
#define PdbOpenFromMemoryCopy_3(out, data, data_size) pdb_open_from_memory_copy((out), (data), (data_size), MisraScope)
#define PdbOpenFromMemoryCopy_4(out, data, data_size, alloc) \
pdb_open_from_memory_copy((out), (data), (data_size), ALLOCATOR_OF(alloc))
///
- In
Dwarf.h:99:
#define DwarfLinesBuildFromElf(...) OVERLOAD(DwarfLinesBuildFromElf, __VA_ARGS__)
#define DwarfLinesBuildFromElf_2(out, elf) dwarf_lines_build_from_elf((out), (elf), MisraScope)
#define DwarfLinesBuildFromElf_3(out, elf, alloc) dwarf_lines_build_from_elf((out), (elf), ALLOCATOR_OF(alloc))
///
- In
Dwarf.h:201:
#define DwarfCfiBuildFromElf(...) OVERLOAD(DwarfCfiBuildFromElf, __VA_ARGS__)
#define DwarfCfiBuildFromElf_2(out, elf) dwarf_cfi_build_from_elf((out), (elf), MisraScope)
#define DwarfCfiBuildFromElf_3(out, elf, alloc) dwarf_cfi_build_from_elf((out), (elf), ALLOCATOR_OF(alloc))
///
- In
Dwarf.h:363:
#define DwarfFunctionsBuildFromElf(...) OVERLOAD(DwarfFunctionsBuildFromElf, __VA_ARGS__)
#define DwarfFunctionsBuildFromElf_2(out, elf) dwarf_functions_build_from_elf((out), (elf), MisraScope)
#define DwarfFunctionsBuildFromElf_3(out, elf, alloc) dwarf_functions_build_from_elf((out), (elf), ALLOCATOR_OF(alloc))
///
- In
Elf.h:269:
_Generic( \
(path), \
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Elf.h:270:
(path), \
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Elf.h:271:
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Elf.h:329:
#define ElfOpenFromMemoryCopy_3(out, data, data_size) elf_open_from_memory_copy((out), (data), (data_size), MisraScope)
#define ElfOpenFromMemoryCopy_4(out, data, data_size, alloc) \
elf_open_from_memory_copy((out), (data), (data_size), ALLOCATOR_OF(alloc))
///
- In
Pe.h:146:
_Generic( \
(path), \
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Pe.h:147:
(path), \
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pe.h:148:
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pe.h:189:
#define PeOpenFromMemoryCopy_3(out, data, data_size) pe_open_from_memory_copy((out), (data), (data_size), MisraScope)
#define PeOpenFromMemoryCopy_4(out, data, data_size, alloc) \
pe_open_from_memory_copy((out), (data), (data_size), ALLOCATOR_OF(alloc))
///
- In
MachO.h:167:
_Generic( \
(path), \
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
MachO.h:168:
(path), \
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
MachO.h:169:
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
MachO.h:212:
macho_open_from_memory_copy((out), (data), (data_size), MisraScope)
#define MachoOpenFromMemoryCopy_4(out, data, data_size, alloc) \
macho_open_from_memory_copy((out), (data), (data_size), ALLOCATOR_OF(alloc))
///
- In
ProcMaps.h:69:
#define ProcMapsLoad(...) OVERLOAD(ProcMapsLoad, __VA_ARGS__)
#define ProcMapsLoad_1(out) proc_maps_load((out), MisraScope)
#define ProcMapsLoad_2(out, alloc) proc_maps_load((out), ALLOCATOR_OF(alloc))
///
- In
Log.c:70:
// FormatStackTrace takes `Allocator *` -- legitimate erasure
// boundary; pass at the call site, no intermediate variable.
FormatStackTrace(&trace, frames, n, ALLOCATOR_OF(&h));
(void)FileWrite(&out, StrBegin(&trace), StrLen(&trace));
StrDeinit(&trace);- In
Debug.c:186:
// intentional bypass: Debug allocator swap; no public MapSetAllocator mutator.
if (!self->live.allocator) {
((DebugAllocator *)(void *)self)->live.allocator = ALLOCATOR_OF(&((DebugAllocator *)(void *)self)->meta);
}
if (!self->freed.allocator) {- In
Debug.c:189:
}
if (!self->freed.allocator) {
((DebugAllocator *)(void *)self)->freed.allocator = ALLOCATOR_OF(&((DebugAllocator *)(void *)self)->meta);
}
if (!(self->base.__magic & MAGIC_VALIDATED_BIT)) {- In
Debug.c:327:
(u64)fe->requested_size
);
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);- In
Debug.c:328:
);
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;- In
Debug.c:353:
(u64)live_rec->requested_size
);
debug_emit_trace(live_rec->alloc_trace, live_rec->alloc_trace_n, "alloc", ALLOCATOR_OF(&self->meta));
}
}- In
Debug.c:473:
MapForeachPairPtr(&self->live, key_ptr, val_ptr) {
LOG_ERROR(" leaked {x} ({} bytes)", (u64)*key_ptr, (u64)val_ptr->requested_size);
debug_emit_trace(val_ptr->alloc_trace, val_ptr->alloc_trace_n, "alloc", ALLOCATOR_OF(&self->meta));
}
}- In
Debug.c:540:
if (val_ptr->alloc_trace_n > 0) {
#if !defined(LOG_NO_BACKTRACE) || !LOG_NO_BACKTRACE
FormatStackTrace(out, val_ptr->alloc_trace, val_ptr->alloc_trace_n, ALLOCATOR_OF(&self->meta));
#else
for (size i = 0; i < val_ptr->alloc_trace_n; ++i) {- In
Dir.c:540:
// by both typed and erased callers) -- legitimate erasure boundary;
// pass at the call site, no intermediate variable.
DirContents dc = dir_get_contents(path, ALLOCATOR_OF(&ha));
bool ok = true;- In
Dns.c:459:
// DnsParseResponse takes `Allocator *` -- legitimate erasure
// boundary; pass at the call site, no intermediate variable.
bool ok = DnsParseResponse(&resp, resp_buf, (u64)got, ALLOCATOR_OF(&scratch));
if (!ok || resp.id != id || resp.rcode != DNS_RCODE_NOERROR) {
DnsResponseDeinit(&resp);- In
Clock.c:113:
DefaultAllocator alloc = DefaultAllocatorInit();
i32 offset = 0;
bool ok = TzifLocalOffsetSeconds((i64)(ns / 1000000000ull), &offset, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
if (ok)- In
Pdb.Blind.c:194:
static bool test_deep_block_count_used(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// SymRecord stream = 50 blocks * 512 = 25600 bytes (> 42 blocks). A
- In
Pdb.Blind.c:233:
static bool test_multiblock_directory_no_overrun(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
// n=130 streams -> dir_bytes = 4 + 130*4 + 4*4 = 540 (bs=512): block 0
- In
Pdb.Blind.c:275:
static bool test_many_sections_no_overrun(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
enum {- In
Pdb.Blind.c:314:
static bool test_symrec_index_equals_num_streams(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[6] = {0, 28, 0, 76, 26, 40};- In
Pdb.Blind.c:343:
static bool test_dbi_ok_reset_on_optdbg_overrun(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Stream 0 is a VALID 40-byte section table (the mutant's wrong
- In
Pdb.Blind.c:374:
static bool test_name_nul_search_excludes_end(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[6] = {0, 28, 0, 76, 64, 40}; static bool copy_self_exe(Zstr dst) {
DefaultAllocator alloc = DefaultAllocatorInit();
Buf bytes = BufInit(ALLOCATOR_OF(&alloc));
bool ok = false;
if (FileReadAndClose("/proc/self/exe", &bytes) >= 0) DebugAllocator alloc = DebugAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false; // pointers, so the pointer compare (l.144) misses and the ZstrCompare
// fallback (l.150) is the only thing that can match them.
Str buf1 = StrInit(ALLOCATOR_OF(&alloc));
Str buf2 = StrInit(ALLOCATOR_OF(&alloc));
StrPushBackMany(&buf1, file); // fallback (l.150) is the only thing that can match them.
Str buf1 = StrInit(ALLOCATOR_OF(&alloc));
Str buf2 = StrInit(ALLOCATOR_OF(&alloc));
StrPushBackMany(&buf1, file);
StrPushBackR(&buf1, '\0');
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false; entry.path = file;
bool ok = ElfOpen(&entry.elf, file, ALLOCATOR_OF(&alloc));
if (ok)
ok = ElfOpen(&entry.sidecar, file, ALLOCATOR_OF(&alloc)); bool ok = ElfOpen(&entry.elf, file, ALLOCATOR_OF(&alloc));
if (ok)
ok = ElfOpen(&entry.sidecar, file, ALLOCATOR_OF(&alloc));
entry.has_sidecar = true;
if (ok)- In
Http.Leak.c:39:
bool test_hl_headers_vec_deinit_releases_values(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
HttpHeaders headers = VecInitWithDeepCopy(http_header_init_copy, http_header_deinit, adbg);- In
Http.Leak.c:83:
bool test_hl_request_deinit_releases_url(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
// A long URL forces the url Str onto the heap.
- In
Http.Leak.c:110:
bool test_hl_respond_with_html_releases_old_body(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
Str first = StrInit(adbg);- In
Http.Leak.c:146:
bool test_hl_respond_with_file_releases_old_body(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
// Pre-fill body with a heap-backed string.
- In
PageProtect.c:8:
bool test_page_protect_roundtrip(void) {
PageAllocator page = PageAllocatorInit();
Allocator *base = ALLOCATOR_OF(&page);
size page_bytes = PageAllocatorPageSize(&page);- In
Pe.c:481:
bool test_pe_parses_synthetic_blob(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_pe_blob();- In
Pe.c:508:
bool test_pe_rva_to_offset_round_trips(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_pe_blob();- In
Pe.c:532:
bool test_pe_rejects_bad_magic(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 garbage[256];- In
Pe.c:550:
bool test_pe_find_section(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_pe_blob();- In
Pe.c:574:
bool test_pe_rva_boundaries(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_pe_blob();- In
Pe.c:602:
DefaultAllocator alloc = DefaultAllocatorInit();
Pe pe;
bool opened = PeOpenFromMemoryCopy(&pe, bytes, len, ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);- In
Pe.c:658:
build_pe_blob_m1();
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:679:
wr_u64(&blob[OPT_HDR_OFF + 24], 0x7766554433221100ull);
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:695:
build_pe32_blob();
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:715:
wr_u32(&blob[OPT_HDR_OFF + 28], 0x00410000u);
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:741:
// confirm the normal (well-within-file) blob is accepted.
Pe pe;
bool ok = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (ok)
PeDeinit(&pe);- In
Pe.c:763:
wr_u16(&bad[FILE_HDR_OFF + 16], 1900);
Pe pe;
bool opened = PeOpenFromMemoryCopy(&pe, bad, sizeof(bad), ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);- In
Pe.c:791:
u64 want_len = (u64)OPT_HDR_OFF + OPT_HDR_SIZE_PEPP; // exact fit to EOF
Pe pe;
bool ok = PeOpenFromMemoryCopy(&pe, exact, want_len, ALLOCATOR_OF(&alloc));
if (ok) {
ok = ok && pe.size_of_image == PE_SIZE_OF_IMAGE;- In
Pe.c:812:
wr_u32(&blob[OPT_HDR_OFF + 108], 7); // NumberOfRvaAndSizes = 7
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:838:
// absent kills that mutation.
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:859:
build_pe_blob_m1();
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:880:
blob[CV_REC_RAW_OFF] = 'N';
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:897:
wr_u32(&blob[DEBUG_RAW_OFF + 12], 9); // Type != CODEVIEW
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:927:
cv[24 + i] = (u8)('A' + i); // no NUL anywhere in the region
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:955:
cv[28] = '\0'; // terminator is the last in-region byte
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:980:
cv[24] = '\0'; // empty path, NUL-terminated
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:996:
wr_u32(&blob[DEBUG_RAW_OFF + 16], 24); // one below minimum
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1020:
wr_u32(&blob[DEBUG_RAW_OFF + 16], (u32)(BLOB_SIZE - CV_REC_RAW_OFF + 4));
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1044:
put_cv_entry_sz(0x300, 0x200, 0x300);
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1064:
put_cv_entry_sz(0x300, 0x500, 0x300);
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1088:
wr_u32(&blob[OPT_HDR_OFF + 112 + 6 * 8 + 4], BLOB_SIZE);
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1118:
put_cv_entry(DIR_RAW, 0x500); // CodeView in entry 0, record at 0x500
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1141:
put_cv_entry(DIR_RAW, 0x500); // record at 0x500 (in-bounds)
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1169:
cv[28] = '\0'; // NUL sits exactly AT region_end (one past the region)
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1196:
put_cv_entry(0x300 + 28, 0x500); // entry1 (just past declared count)
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1237:
MemCopy(&cv2[24], kPdbPath, plen + 1);
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1273:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1309:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, total, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1335:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1367:
Pe pe;
bool opened = PeOpenFromMemoryCopy(&pe, blob, total, ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);- In
Pe.c:1401:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1435:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1474:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, total, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1506:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1540:
Pe pe;
if (!PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Pe.c:1575:
Pe pe;
bool opened = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
// Real code: rejected AND `out` zeroed by PeDeinit on the fail path.
bool ok = !opened && BufData(&pe.data) == NULL && BufLength(&pe.data) == 0 && VecLen(&pe.sections) == 0;- In
Pe.c:1595:
static bool test_pe2_open_valid_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecDesc secs[1];- In
Pe.c:1641:
static bool test_pe2_open_nonpe_file_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 junk[256];- In
Pe.c:1691:
Pe pe;
bool ok = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (ok)
PeDeinit(&pe);- In
Pe.c:1712:
Pe pe;
bool opened = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);- In
Int.Convert.c:88:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(13, ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value); u8 bytes[] = {0x34, 0x12, 0xEF, 0xCD};
u8 out[4] = {0};
Int value = IntFromBytesLE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesLE(&value, out, sizeof(out));
Str text = IntToHexStr(&value); u8 bytes[] = {0x12, 0x34, 0x56, 0x78};
u8 out[4] = {0};
Int value = IntFromBytesBE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesBE(&value, out, sizeof(out));
Str text = IntToHexStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("001011", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStrRadix("zz", 36, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 36, false); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 16, true); alloc.base.retry_limit = 4;
Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
ok = int_try_to_str_radix(&text, &value, 16, true, ALLOCATOR_OF(&alloc)); Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
ok = int_try_to_str_radix(&text, &value, 16, true, ALLOCATOR_OF(&alloc));
bool result = ok && (ZstrCompare(StrBegin(&text), "BEEF") == 0) && DefaultAllocator alloc = DefaultAllocatorInit();
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));
bool result = IntCompare(&lhs, &rhs) == 0; DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntFromBinary("0", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&zero);
bool error = true; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0b1010_0011", ALLOCATOR_OF(&alloc));
bool result = IntToU64(&value) == 163; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromOctStr("0o7_55", ALLOCATOR_OF(&alloc));
Str text = IntToOctStr(&value);
Zstr hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
Str text = IntToHexStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1");
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1"); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3");
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3"); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3");
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3"); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2);
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1);
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u64 out = 0;
bool error = false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(255, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 37, false); DefaultAllocator alloc = DefaultAllocatorInit();
IntFromBinary((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromBinary(&value, (Zstr)NULL);
IntDeinit(&value); DefaultAllocator alloc = DefaultAllocatorInit();
IntFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStr(&value, (Zstr)NULL);
IntDeinit(&value); DefaultAllocator alloc = DefaultAllocatorInit();
IntFromStrRadix((Zstr)NULL, 10, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStrRadix(&value, (Zstr)NULL, 10);
IntDeinit(&value); DefaultAllocator alloc = DefaultAllocatorInit();
IntFromOctStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromOctStr(&value, (Zstr)NULL);
IntDeinit(&value); DefaultAllocator alloc = DefaultAllocatorInit();
IntFromHexStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromHexStr(&value, (Zstr)NULL);
IntDeinit(&value); DefaultAllocator alloc = DefaultAllocatorInit();
IntFromBytesLE(NULL, 1, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
IntToBytesLE(&value, NULL, 1);
DefaultAllocatorDeinit(&alloc); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 byte = 0; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "_", 10); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, "7", 10);
bool result = ok && (IntToU64(&value) == 7); DefaultAllocator alloc = DefaultAllocatorInit();
Int valid = IntInit(ALLOCATOR_OF(&alloc));
Int invalid = IntInit(ALLOCATOR_OF(&alloc));
Int valid = IntInit(ALLOCATOR_OF(&alloc));
Int invalid = IntInit(ALLOCATOR_OF(&alloc));
bool ok_valid = IntTryFromStrRadix(&valid, "5", 10); DefaultAllocator alloc = DefaultAllocatorInit();
Str digits = StrInitFromZstr("123", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);
Str digits = StrInitFromZstr("123", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10); DefaultAllocator alloc = DefaultAllocatorInit();
Str digits = StrInitFromZstr("+5", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);
Str digits = StrInitFromZstr("+5", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0x1234, ALLOCATOR_OF(&alloc));
u8 out[8] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesLE(&value, out, sizeof(out)); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 out[4] = {0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesLE(&value, out, sizeof(out)); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0x1234, ALLOCATOR_OF(&alloc));
u8 out[8] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesBE(&value, out, sizeof(out)); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 out[4] = {0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesBE(&value, out, sizeof(out)); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBytesLE(NULL, 0, ALLOCATOR_OF(&alloc));
bool result = IntIsZero(&value);
u8 bytes[] = {0x05, 0x00};
Int value = IntFromBytesLE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
bool result = (IntToU64(&value) == 5); DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; WriteFmt("Testing BitVecPop\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
WriteFmt("Testing BitVecRemove (single bit)\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
WriteFmt("Testing BitVecRemoveRange\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, true, false, true
WriteFmt("Testing BitVecRemoveFirst\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
WriteFmt("Testing BitVecRemoveLast\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true
WriteFmt("Testing BitVecRemoveAll\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits: true, false, true, false, true, false
WriteFmt("Testing BitVecPop edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemove edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemoveRange edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemoveFirst/Last edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRemoveAll edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec remove invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test removing beyond capacity limit - should abort
WriteFmt("Testing BitVec pop bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test pop from empty bitvec - should abort
WriteFmt("Testing BitVec remove bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test remove from empty bitvec - should abort
WriteFmt("Testing BitVec remove range bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test remove range from empty bitvec - should abort
WriteFmt("Testing BitVecRemoveRange clamps oversized count\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Length 10, all true.
WriteFmt("Testing BitVecRemoveRange clamp gap count\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Length 10, all true.
WriteFmt("Testing BitVecRemoveRange shifts tail down\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Pattern: indices 0..9 = [1,0,1,0,0,1,0,1,1,0]
WriteFmt("Testing BitVecRemove rejects idx == length\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false);- In
PdbCache.c:269:
bool test_pdb_cache_resolves_via_codeview(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
char pe_path[1024];- In
PdbCache.c:317:
bool test_pdb_cache_rejects_unknown_module(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
char missing[1024];- In
File.Blind.c:23:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
// Open file A and keep a second file B open so A's fd slot sits in the
WriteFmt("Testing BitVec get bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test get from empty bitvec - should abort
WriteFmt("Testing BitVec set bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test set on empty bitvec - should abort
WriteFmt("Testing BitVec flip bounds checking\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test flip on empty bitvec - should abort
WriteFmt("Testing BitVec get with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false); WriteFmt("Testing BitVec set with large out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
BitVecPush(&bv, false); WriteFmt("Testing BitVec flip with edge case out-of-bounds index\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 10; i++) {
BitVecPush(&bv, i % 2 == 0); WriteFmt("Testing BitVec get with maximum index value\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); WriteFmt("Testing BitVecPush\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
WriteFmt("Testing BitVecInsert (single bit)\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Insert at index 0 (empty bitvector)
WriteFmt("Testing BitVecInsertRange\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create target bitvector
WriteFmt("Testing BitVecInsertMultiple\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
// Start with some bits
WriteFmt("Testing BitVecInsertPattern\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Start with some bits
// Test with different pattern - 0x05 (0101 in binary) using only 3 bits
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true); WriteFmt("Testing BitVecInsertRange edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecInsertMultiple edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecInsertPattern edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec insert invalid range handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test inserting beyond capacity limit - should abort
WriteFmt("Testing BitVecInsertRange shifts existing tail bits\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Original: [1, 0, 1, 1]
WriteFmt("Testing BitVecInsertMultiple shifts existing tail bits\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec other = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec other = BitVecInit(ALLOCATOR_OF(&alloc));
// bv: [1, 0, 1]
WriteFmt("Testing BitVecInsertMultiple NULL bv validation\n");
BitVec other = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&other, true); WriteFmt("Testing BitVecInsertMultiple NULL other validation\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false;- In
SysDns.Api.c:119:
static bool test_sd4_resolve5_single_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:139:
static bool test_sd4_resolve5_multi_two_in_order(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:160:
static bool test_sd4_resolve5_both_families(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:181:
static bool test_sd4_resolve5_v6_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:201:
static bool test_sd4_resolve5_normalized_match(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:222:
static bool test_sd4_resolve5_miss_no_ns(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:242:
static bool test_sd4_resolve5_overlong_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:272:
static bool test_sd4_resolve5_exact_256_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:301:
static bool test_sd4_resolve5_under_cap_processed(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:339:
static bool test_sd4_resolve5_empty_name_row_ignored(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:364:
static bool test_sd4_resolve5_str_delegates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:392:
static bool test_sd4_resolve4_vec_single(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:411:
static bool test_sd4_resolve4_vec_multi(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:432:
static bool test_sd4_resolve4_vec_numeric(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:451:
static bool test_sd4_resolve4_vec_no_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:471:
static bool test_sd4_resolve4_vec_empty_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:491:
static bool test_sd4_resolve4_vec_bad_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:512:
static bool test_sd4_resolve4_vec_max_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:535:
static bool test_sd4_resolve4_vec_host_256_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:565:
static bool test_sd4_resolve4_vec_absent(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:587:
static bool test_sd4_resolve4_vec_str_delegates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:613:
static bool test_sd4_resolve4_one_single(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:632:
static bool test_sd4_resolve4_one_first_of_many(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:650:
static bool test_sd4_resolve4_one_miss(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:671:
static bool test_sd4_resolve4_one_str_delegates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:697:
static bool test_sd4_init_defaults(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:716:
static bool test_sd4_init_loads_hosts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:746:
static bool test_sd4_init_loads_nameservers(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Api.c:778:
static bool test_sd4_deinit_no_leak(void) {
DebugAllocator alloc = DebugAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
size baseline = DebugAllocatorLiveCount(&alloc);- In
Elf.Blind.c:121:
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, buf, sizeof(buf), ALLOCATOR_OF(&alloc));
if (opened)
ElfDeinit(&elf);- In
Io.Write.c:531:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:595:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:641:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:1410:
static bool test_m12_hex_min_width_is_four(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:1428:
static bool test_m12_hex_width_tracks_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:1444:
static bool test_m12_hex_cursor_advances(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:1463:
static bool test_m12_octal_min_width_is_three(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:1482:
static bool test_m12_octal_accepts_zero_digit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:1499:
static bool test_m12_octal_width_tracks_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:1976:
static bool test_m17_sci_single_digit_no_point(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:1996:
static bool test_m17_sci_zero_precision_zero_no_point(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:2018:
static bool test_m17_sci_zero_precision_three_zeros(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:2039:
static bool test_m17_sci_frac_digit_vs_pad_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:2059:
static bool test_m17_sci_value_and_uppercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:2381:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2411:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2437:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2463:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2487:
static bool test_m23_clz_hex_3ff_bit_len_10(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:2506:
static bool test_m23_clz_hex_ff_bit_len_8(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:2525:
static bool test_m23_clz_hex_10000_bit_len_17(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(alloc_base);- In
Io.Write.c:2710:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2732:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2755:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2777:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:2799:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool success = true;- In
Io.Write.c:3225:
static bool test_m29_write_int_char_single(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:3244:
static bool test_m29_write_int_char_single_alt(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:3269:
static bool test_m29_write_int_width_content_len(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:3630:
static bool test_m31_float_sci_default_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);- In
Io.Write.c:3649:
static bool test_m31_float_sci_explicit_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);- In
Io.Write.c:3674:
static bool test_m31_float_width_uses_just_written_len(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.2", alloc_base);- In
Io.Write.c:3714:
static bool test_m32_bitvec_width_uses_field_length(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);- In
Io.Write.c:3817:
static bool test_m33_int_octal_stops_at_radix_digit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Int oct = IntInit(alloc_base);- In
Io.Write.c:3838:
static bool test_m33_write_zstralloc_emits(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);- In
Io.Write.c:3994:
bool test_if_1397_float_trailing_zero_padding(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
bool ok = true;- In
Io.Write.c:4404:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "9z";
StrReadFmt(z, "{}", v);- In
Io.Write.c:4421:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "5";
StrReadFmt(z, "{}", v);- In
Io.Write.c:4437:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "+8";
StrReadFmt(z, "{}", v);- In
Io.Write.c:4501:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "ff";
StrReadFmt(z, "{x}", v);- In
Io.Write.c:4544:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "101";
StrReadFmt(z, "{b}", v);- In
Io.Write.c:4587:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "17";
StrReadFmt(z, "{o}", v);- In
Io.Write.c:4602:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = " 42";
StrReadFmt(z, "{}", v); ProcMaps pm;
MemSet(&pm, 0, sizeof(pm));
pm.raw = StrInit(ALLOCATOR_OF(&alloc));
pm.entries = VecInitT(pm.entries, ALLOCATOR_OF(&alloc)); MemSet(&pm, 0, sizeof(pm));
pm.raw = StrInit(ALLOCATOR_OF(&alloc));
pm.entries = VecInitT(pm.entries, ALLOCATOR_OF(&alloc));
ProcMapEntry e0 = {.start = 0x1000, .end = 0x2000, .perms = 0, .file_offset = 0, .path = ""}; DefaultAllocator alloc = DefaultAllocatorInit();
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 256; i++) {
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 256; i++) {
BitVecPush(&a, false);
Str s = StrInitFromZstr("111000111", &alloc);
BitVec bv = bitvec_from_str_str(&s, ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&bv) == 9) && (BitVecCountOnes(&bv) == 6);
for (int i = 0; i < 9; i++) { bool test_blind_rotate_right_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool pat[5] = {true, false, false, true, true}; static bool bl_fmt_eq(Zstr spec, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr addr; bool test_bl_fill_length_is_real_16(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr bind_addr; static bool bid_fragment_eq(const u8 *id, u32 n, const char *expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&alloc));
append_build_id_path(&out, id, n);
StrPushBackR(&out, '\0'); // terminate so ZstrCompare is well-defined
bool test_sr2_bid_full_path(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&alloc));
StrPushBackMany(&out, "/usr/lib/debug/.build-id/");
const u8 id[] = {0xab, 0xcd, 0xef, 0x01, 0x23}; static bool copy_self_exe(Zstr dst) {
DefaultAllocator alloc = DefaultAllocatorInit();
Buf bytes = BufInit(ALLOCATOR_OF(&alloc));
bool ok = false;
if (FileReadAndClose("/proc/self/exe", &bytes) >= 0) { MemSet(&out, 0, sizeof(out));
// main_path lives in `dir`; its basename is irrelevant (no real file).
bool ok = try_open_sidecar("/tmp/sr2_adj/fakebin", &main, &out, ALLOCATOR_OF(&alloc));
if (ok)
ElfDeinit(&out); Elf out;
MemSet(&out, 0, sizeof(out));
bool ok = try_open_sidecar("/tmp/sr2_sub/fakebin", &main, &out, ALLOCATOR_OF(&alloc));
if (ok)
ElfDeinit(&out); Elf out;
MemSet(&out, 0, sizeof(out));
bool ok = try_open_sidecar("/tmp/sr2_none/fakebin", &main, &out, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok == false; Elf out;
MemSet(&out, 0, sizeof(out));
bool ok = try_open_sidecar("/tmp/sr2_miss/fakebin", &main, &out, ALLOCATOR_OF(&alloc));
DirRemoveAll(dir); Elf out;
MemSet(&out, 0, sizeof(out));
bool ok = try_open_sidecar("/tmp/sr2_bad/fakebin", &main, &out, ALLOCATOR_OF(&alloc));
DirRemoveAll(dir); Elf out;
MemSet(&out, 0, sizeof(out));
bool ok = try_open_sidecar("/tmp/sr2_sub_bad/fakebin", &main, &out, ALLOCATOR_OF(&alloc));
DirRemoveAll(dir); DebugAllocator alloc = DebugAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false; DebugAllocator alloc = DebugAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false; DebugAllocator alloc = DebugAllocatorInit();
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false;
SymbolResolver res;
if (!SymbolResolverInit(&res, ALLOCATOR_OF(&alloc)))
return false;- In
Map.Type.c:177:
MapValueCopyInit(&map) == (GenericCopyInit)zstr_init_clone &&
MapValueCopyDeinit(&map) == (GenericCopyDeinit)zstr_deinit &&
MapAllocator(&map) == ALLOCATOR_OF(&alloc);
MapDeinit(&map); WriteFmt("Testing BitVecGet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
WriteFmt("Testing BitVecSet\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Reserve space and set bits
WriteFmt("Testing BitVecFlip\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push some bits
WriteFmt("Testing BitVecLength and BitVecCapacity\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Initially empty
WriteFmt("Testing BitVecCount operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Push a pattern: true, false, true, false, true
WriteFmt("Testing BitVecGet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecSet edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set first bit
WriteFmt("Testing BitVecFlip edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test flipping single bit
WriteFmt("Testing BitVecCount edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec multiple access operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec access with large patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec macro functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec access stress test\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec comprehensive bit patterns\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFind functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec predicate functions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecLongestRun\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFind edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec predicate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecLongestRun edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecAnd\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1101
WriteFmt("Testing BitVecOr\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1100
WriteFmt("Testing BitVecXor\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector: 1100
WriteFmt("Testing BitVecNot\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1010
WriteFmt("Testing BitVecShiftLeft\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011 (indices 0,1,2,3)
WriteFmt("Testing BitVecShiftRight\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVecRotateLeft\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVecRotateRight\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVecReverse\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up bitvector: 1011
WriteFmt("Testing BitVec shift edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec rotate edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec bitwise operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test operations on empty bitvecs
BitVec result_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecAnd(&result_bv, &bv1, &bv2);
result = result && (BitVecLen(&result_bv) == 0); WriteFmt("Testing BitVecReverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec comprehensive bitwise operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; WriteFmt("Testing BitVec comprehensive shift operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec comprehensive rotate operations\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec bitwise identity operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; WriteFmt("Testing BitVec bitwise commutative properties\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; WriteFmt("Testing BitVec bitwise operations with large patterns\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
bool test_result = true; WriteFmt("Testing BitVecOr widens past shorter operand a\n");
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// a = 10 (len 2)
WriteFmt("Testing BitVecXor widens past shorter operand a\n");
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// a = 10 (len 2)
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 8; i++) {
BitVecPush(&bv, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); // bit 0
BitVecPush(&bv, true); // bit 1
static bool test_basic_alloc_and_free(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(Node));
Allocator *alloc_base = ALLOCATOR_OF(&slab);
Node *a = (Node *)AllocatorAlloc(alloc_base, sizeof(Node), true);
Node *b = (Node *)AllocatorAlloc(alloc_base, sizeof(Node), true); static bool test_free_then_alloc_recycles(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(Node));
Allocator *alloc_base = ALLOCATOR_OF(&slab);
Node *a = (Node *)AllocatorAlloc(alloc_base, sizeof(Node), true);
bool ok = (a != NULL); static bool test_grow_across_chunks(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(Node));
Allocator *alloc_base = ALLOCATOR_OF(&slab);
Node *slots[600];
bool ok = true; static bool test_oversized_request_fails(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(int));
Allocator *alloc_base = ALLOCATOR_OF(&slab);
void *big = AllocatorAlloc(alloc_base, 4096, true);
bool ok = (big == NULL); static bool test_free_half_then_realloc(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(Node));
Allocator *alloc_base = ALLOCATOR_OF(&slab);
Node *slots[200];
bool ok = true; static bool test_pool_alignment(void) {
SlabAllocator slab = SlabAllocatorInitAligned(sizeof(int), 64);
Allocator *alloc_base = ALLOCATOR_OF(&slab);
int *p = (int *)AllocatorAlloc(alloc_base, sizeof(int), true);
bool ok = (p != NULL) && (((u64)p & 63u) == 0); SlabAllocator s1 = SlabAllocatorInit(sizeof(Node));
SlabAllocator s2 = SlabAllocatorInit(sizeof(Node));
Allocator *a1 = ALLOCATOR_OF(&s1);
Allocator *a2 = ALLOCATOR_OF(&s2);
Node *p = (Node *)AllocatorAlloc(a1, sizeof(Node), false); SlabAllocator s2 = SlabAllocatorInit(sizeof(Node));
Allocator *a1 = ALLOCATOR_OF(&s1);
Allocator *a2 = ALLOCATOR_OF(&s2);
Node *p = (Node *)AllocatorAlloc(a1, sizeof(Node), false);
AllocatorFree(a2, p); // foreign to s2 -> LOG_FATAL
static bool test_reject_misaligned_pointer(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&slab);
u8 *p = (u8 *)AllocatorAlloc(alloc, sizeof(Node), false);
AllocatorFree(alloc, p + 1); // mis-aligned -> LOG_FATAL
static bool test_reject_double_free(void) {
SlabAllocator slab = SlabAllocatorInit(sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&slab);
Node *p = (Node *)AllocatorAlloc(alloc, sizeof(Node), false);
AllocatorFree(alloc, p); WriteFmt("Testing BitVecToStr\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1011
Zstr str = "1011";
BitVec bv;
bool ok = BitVecTryFromStr(&bv, str, ALLOCATOR_OF(&alloc));
// Check result
// Test with empty string
BitVec empty_bv = BitVecFromStr("", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&empty_bv) == 0); WriteFmt("Testing BitVecToBytes\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 10110011 (0xB3)
u8 bytes[] = {0xB3}; // 10110011 in binary
BitVec bv;
bool ok = BitVecTryFromBytes(&bv, bytes, 8, ALLOCATOR_OF(&alloc)); // 8 bits from the byte
// Check result (8 bits from 1 byte)
WriteFmt("Testing BitVecToInteger\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern: 1011 (decimal 11 if MSB first, 13 if LSB first)
// Test with larger pattern
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 8; i++) {
BitVecPush(&bv2, (i % 2 == 0)); // Alternating pattern
u64 value = 11; // 1011 in binary
BitVec bv;
bool ok = BitVecTryFromInteger(&bv, value, 4, ALLOCATOR_OF(&alloc));
// Check result
// Test with zero
BitVec zero_bv;
result = result && BitVecTryFromInteger(&zero_bv, 0, 8, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&zero_bv) == 8); BitVec bv;
Str str;
bool ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));
bool result = ok && (BitVecAllocator(&bv)->effort == alloc.base.effort) &&
(BitVecAllocator(&bv)->retry_limit == alloc.base.retry_limit);
u8 dummy_bytes[1] = {0xFF};
BitVec empty_bv = BitVecFromBytes(dummy_bytes, 0, ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&empty_bv) == 0);
BitVecDeinit(&empty_bv); WriteFmt("Testing BitVec convert edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test empty string
BitVec bv1 = BitVecFromStr("", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv1) == 0);
BitVecDeinit(&bv1);
// Test single character
BitVec bv2 = BitVecFromStr("1", ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv2) == 1);
result = result && (BitVecGet(&bv2, 0) == true); long_str[1000] = '\0';
BitVec bv3 = BitVecFromStr(long_str, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&bv3) == 1000);
result = result && (BitVecGet(&bv3, 0) == true); WriteFmt("Testing BitVec bytes conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Test bytes to bitvec with 0 bits (should return empty bitvector)
u8 empty_bytes[1] = {0x05};
BitVec bv2 = BitVecFromBytes(empty_bytes, 0, ALLOCATOR_OF(&alloc)); // 0 bits
result = result && (BitVecLen(&bv2) == 0);
BitVecDeinit(&bv2); // Test single byte
u8 single_byte[1] = {0xFF};
BitVec bv3 = BitVecFromBytes(single_byte, 8, ALLOCATOR_OF(&alloc)); // 8 bits from 1 byte
result = result && (BitVecLen(&bv3) == 8);
BitVecDeinit(&bv3); WriteFmt("Testing BitVec integer conversion edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test integer to bitvec with 0
BitVec bv2 = BitVecFromInteger(0, 8, ALLOCATOR_OF(&alloc)); // 8 bits for zero
result = result && (BitVecLen(&bv2) == 8); // Should be 8 bits
BitVecDeinit(&bv2);
// Test large integer
BitVec bv3 = BitVecFromInteger(UINT64_MAX, 64, ALLOCATOR_OF(&alloc)); // 64 bits for max value
result = result && (BitVecLen(&bv3) == 64);
BitVecDeinit(&bv3);
for (size i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
BitVec bv = BitVecFromStr(patterns[i], ALLOCATOR_OF(&alloc));
Str str = BitVecToStr(&bv); value &= mask;
BitVec bv = BitVecFromInteger(value, bits, ALLOCATOR_OF(&alloc));
u64 recovered = BitVecToInteger(&bv);
for (size i = 0; i < sizeof(test_bytes); i++) {
BitVec bv = BitVecFromBytes(&test_bytes[i], 8, ALLOCATOR_OF(&alloc));
u8 recovered_byte = 0;
u64 written = BitVecToBytes(&bv, &recovered_byte, 1);
// Test large integer conversion (should cap at 64 bits)
BitVec large_bv = BitVecFromInteger(0xFFFFFFFFFFFFFFFF, 64, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&large_bv) == 64);
// Test oversized bitvec to integer (should handle gracefully)
BitVec oversized = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 100; i++) { // 100 bits > 64 bit limit
BitVecPush(&oversized, i % 2 == 0);
// Test zero-length conversions
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
Str empty_str = BitVecToStr(&empty);
for (size i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); i++) {
BitVec bv = BitVecFromStr(test_cases[i].pattern, ALLOCATOR_OF(&alloc));
// Test string conversion consistency
// FromInteger(0xD6, 8) -> bit[i]=(0xD6>>i)&1 -> "01101011"
// FromBytes({0xD6}, 8) -> bit[i]=(0xD6>>i)&1 -> "01101011"
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc)); // FromBytes({0xD6}, 8) -> bit[i]=(0xD6>>i)&1 -> "01101011"
BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecFromStr("11010110", ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecFromInteger(0xD6, 8, ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
Str str1 = BitVecToStr(&bv1);
// Test with very large bitvectors
BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create a 1000-bit pattern
// Test round-trip from bytes
BitVec recovered_bv = BitVecFromBytes(large_bytes, 1000, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&recovered_bv) == 1000); large_pattern[2000] = '\0';
BitVec large_from_str = BitVecFromStr(large_pattern, ALLOCATOR_OF(&alloc));
result = result && (BitVecLen(&large_from_str) == 2000); WriteFmt("Testing BitVec bytes zero max_len handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true); // function-level ValidateBitVec instead of dereferencing NULL
// inside the BitVecAllocator accessor macro.
BitVecToStr((BitVec *)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
// Test NULL string - should abort
BitVecFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
// Test NULL bytes - should abort
BitVecFromBytes(NULL, 8, ALLOCATOR_OF(&alloc)); // NULL bytes, 8 bits
DefaultAllocatorDeinit(&alloc);
BitVec bv;
bool ok = BitVecTryFromInteger(&bv, 0xFFu, 100, ALLOCATOR_OF(&alloc));
bool result = ok && (BitVecLen(&bv) == 64); WriteFmt("Testing BitVecToBytes 4-bit pack does not over-read\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// 4-bit pattern 1011 -> LSB-first packing: bits 0,2,3 set -> 0x0D.
BitVecPush(&bv, true); // bit 0
WriteFmt("Testing BitVecToBytes truncation respects max_len\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// 16 bits; ensure byte 1 has at least one set bit (bit 8 -> byte1 bit0).
for (u64 i = 0; i < 16; i++) {- In
Dns.c:14:
static bool test_dns_build_query_basic(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsWireBuf buf = VecInitT(buf, a);- In
Dns.c:41:
static bool test_dns_build_query_trailing_dot(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsWireBuf no_dot = VecInitT(no_dot, a);- In
Dns.c:64:
static bool test_dns_parse_response_a_and_aaaa(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// Wire bytes for the response to a query for "example.com" type A:
- In
Dns.c:178:
static bool test_dns_parse_response_nxdomain(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:231:
static bool test_dns_parse_response_cname(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// Response to "www.example.com" type A with one CNAME answer
- In
Dns.c:312:
static bool test_dn1_encode_exact_bytes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsWireBuf buf = VecInitT(buf, a);- In
Dns.c:336:
static bool test_dn1_encode_root(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsWireBuf buf = VecInitT(buf, a);- In
Dns.c:354:
static bool test_dn1_encode_label_63_accepted(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
char label[64];- In
Dns.c:379:
static bool test_dn1_encode_trailing_dot_accepted(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsWireBuf no_dot = VecInitT(no_dot, a);- In
Dns.c:418:
static bool test_dn1_encode_total_init_220(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// labels 63,63,63,27 -> wire total = 64+64+64+28 = 220.
- In
Dns.c:441:
static bool test_dn1_encode_total_254_accepted(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// labels 63,63,63,61 -> wire total = 64+64+64+62 = 254.
- In
Dns.c:468:
static bool test_dn1_build_query_str_path(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Str name = StrInitFromZstr("example.com", a);- In
Dns.c:504:
static bool test_dn1_decode_compressed_answer(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:583:
static bool test_dn1_decode_namelen_no_underflow(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:631:
static bool test_dn1_decode_namelen_253_accepted(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// labels 63,63,63,61 -> dotted length = 250 chars + 3 dots = 253.
- In
Dns.c:676:
static bool test_dn1_decode_bigoffset_pointer(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// Layout: header(12) + Q1 (huge name padding to push Q2 to offset 256) +
- In
Dns.c:755:
static bool test_dn1_decode_backward_pointer_ok(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:823:
static bool test_dn1_decode_label_overrun_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// Question name claims a 10-byte label but only a few bytes follow and
- In
Dns.c:861:
static bool test_dn1_decode_forward_pointer_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// Question name is a single pointer at offset 12 pointing to offset 12
- In
Dns.c:909:
static bool test_dn2_header_only_min_length(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// id=0xABCD flags=0x8180 qd=0 an=0 ns=0 ar=0 -- exactly 12 bytes.
- In
Dns.c:928:
static bool test_dn2_header_too_short_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};- In
Dns.c:952:
static bool test_dn2_flags_decoded(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// flags = 0x8580 = 1000 0101 1000 0000
- In
Dns.c:976:
static bool test_dn2_flags_all_clear_but_tc(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};- In
Dns.c:995:
static bool test_dn2_rcode_low_nibble(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {0x00, 0x01, 0x81, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};- In
Dns.c:1018:
static bool test_dn2_a_record_fields(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1099:
static bool test_dn2_record_class_preserved(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {0x00, 0x00, 0x81, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,- In
Dns.c:1123:
static bool test_dn2_ttl_big_endian(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {0x00, 0x00, 0x81, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,- In
Dns.c:1153:
static bool test_dn2_aaaa_record_fields(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1248:
static bool test_dn2_record_list_two_records(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1322:
static bool test_dn2_three_sections(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1421:
static bool test_dn2_question_skipped_then_answer(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1480:
static bool test_dn2_cname_target(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1536:
static bool test_dn2_rdlength_overrun_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1557:
static bool test_dn2_a_record_wrong_rdlen_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
Dns.c:1593:
static bool test_df_encode_empty_internal_label_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsWireBuf buf = VecInitT(buf, a);- In
Dns.c:1635:
static bool test_df_decode_namelen_cap_rejects(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// labels 63,63,63,62 -> wire 64+64+64+63 = 255, + terminator = 256.
- In
Dns.c:1673:
static bool test_df_decode_namelen_253_accepts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 lens[] = {63, 63, 63, 61};- In
Dns.c:1723:
static bool test_df_decode_truncated_rdata_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
u8 wire[256];- In
Dns.c:1780:
static bool test_df_decode_exact_rdata_accepted(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
static const u8 wire[] = {- In
BitVec.Type.c:21:
// Create a bitvector
BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
// Check initial state
- In
BitVec.Type.c:42:
// Create a valid bitvector
BitVec bitvec = BitVecInit(ALLOCATOR_OF(&alloc));
// This should not abort
- In
File.c:34:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:68:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:106:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:139:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:172:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:215:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:250:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:285:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:320:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
// Need a path on disk; create+remove a temp to mint a unique name,
- In
File.c:355:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
// Mint a unique name then remove it so the path is guaranteed absent.
- In
File.c:387:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:414:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:450:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:508:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:550:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:576:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:606:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:635:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:668:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:704:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:740:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:773:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:810:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
// Build a 10000-byte payload (> FILE_READ_CHUNK=4096) on disk.
- In
File.c:857:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:890:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:920:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:955:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:993:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:1022:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str p1;- In
File.c:1066:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;- In
File.c:1098:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path; u8 buf[1024] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
Node *a = (Node *)AllocatorAlloc(alloc, sizeof(Node), true);
Node *b = (Node *)AllocatorAlloc(alloc, sizeof(Node), true); u8 buf[256] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
void *p = AllocatorAlloc(alloc, 0, false);
BudgetAllocatorDeinit(&bp); u8 buf[256] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
AllocatorFree(alloc, NULL);
void *p = AllocatorAlloc(alloc, sizeof(Node), false); u8 buf[256] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
bool ok = BudgetAllocatorSlotCount(&bp) > 0; u8 buf[1024] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
Node *a = (Node *)AllocatorAlloc(alloc, sizeof(Node), true); u8 buf[1024] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
Node *a = (Node *)AllocatorAlloc(alloc, sizeof(Node), false); u8 buf[256] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(int));
Allocator *alloc = ALLOCATOR_OF(&bp);
void *big = AllocatorAlloc(alloc, 4096, true);
bool ok = (big == NULL); MemSet(buf, 0, sizeof(buf));
BudgetAllocator bp = BudgetAllocatorInitAligned(buf, sizeof(buf), sizeof(int), 64);
Allocator *alloc = ALLOCATOR_OF(&bp);
int *p1 = (int *)AllocatorAlloc(alloc, sizeof(int), true);
int *p2 = (int *)AllocatorAlloc(alloc, sizeof(int), true); BudgetAllocator bp1 = BudgetAllocatorInit(buf1, sizeof(buf1), sizeof(Node));
BudgetAllocator bp2 = BudgetAllocatorInit(buf2, sizeof(buf2), sizeof(Node));
Allocator *alloc1 = ALLOCATOR_OF(&bp1);
Allocator *alloc2 = ALLOCATOR_OF(&bp2); BudgetAllocator bp2 = BudgetAllocatorInit(buf2, sizeof(buf2), sizeof(Node));
Allocator *alloc1 = ALLOCATOR_OF(&bp1);
Allocator *alloc2 = ALLOCATOR_OF(&bp2);
Node *p = (Node *)AllocatorAlloc(alloc1, sizeof(Node), false); u8 buf[1024] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
// intentional bypass: the bitmap pointer is private allocator
u8 buf[1024] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
char *p = (char *)AllocatorAlloc(alloc, sizeof(Node), false);
AllocatorFree(alloc, p + 1); // mis-aligned -> LOG_FATAL
u8 buf[1024] = {0};
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), sizeof(Node));
Allocator *alloc = ALLOCATOR_OF(&bp);
Node *p = (Node *)AllocatorAlloc(alloc, sizeof(Node), false);
AllocatorFree(alloc, p); static bool test_basic_alloc_free(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
u8 *a = (u8 *)AllocatorAlloc(alloc, 32, true); static bool test_zeroed_alloc(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
u8 *p = (u8 *)AllocatorAlloc(alloc, 64, true); static bool test_zero_byte_alloc_returns_null(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
void *p = AllocatorAlloc(alloc, 0, false); static bool test_free_null_is_noop(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
// Must be silent + harmless.
// After the third alloc, bits 0..2 of bitmap_32 should be set.
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
void *a = AllocatorAlloc(alloc, 32, false); static bool test_free_then_alloc_recycles(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
void *a = AllocatorAlloc(alloc, 32, false); };
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
void **ptrs = (void **)AllocatorAlloc(alloc, (size)(N * sizeof(void *)), true); // distinct class and provisions its own page(s).
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
size sizes[] = {16, 32, 64, 128, 256, 512, 1024, 2048}; // > 2 KiB hits the XL path.
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
size n = 64 * 1024; static bool test_overaligned_alloc(void) {
HeapAllocator heap = HeapAllocatorInitAligned(64);
Allocator *alloc = ALLOCATOR_OF(&heap);
void *p = AllocatorAlloc(alloc, 256, true); static bool test_realloc_same_bin_keeps_pointer(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
// 28 and 30 both round up to the 32-byte class in the current
static bool test_realloc_cross_bin_copies(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
u8 *p = (u8 *)AllocatorAlloc(alloc, 16, true); HeapAllocator h1 = HeapAllocatorInit();
HeapAllocator h2 = HeapAllocatorInit();
Allocator *alloc1 = ALLOCATOR_OF(&h1);
Allocator *alloc2 = ALLOCATOR_OF(&h2); HeapAllocator h2 = HeapAllocatorInit();
Allocator *alloc1 = ALLOCATOR_OF(&h1);
Allocator *alloc2 = ALLOCATOR_OF(&h2);
void *a = AllocatorAlloc(alloc1, 32, true); HeapAllocator h1 = HeapAllocatorInit();
HeapAllocator h2 = HeapAllocatorInit();
Allocator *alloc1 = ALLOCATOR_OF(&h1);
Allocator *alloc2 = ALLOCATOR_OF(&h2);
void *p = AllocatorAlloc(alloc1, 32, false); HeapAllocator h2 = HeapAllocatorInit();
Allocator *alloc1 = ALLOCATOR_OF(&h1);
Allocator *alloc2 = ALLOCATOR_OF(&h2);
void *p = AllocatorAlloc(alloc1, 32, false);
AllocatorFree(alloc2, p); // foreign to h2 -> LOG_FATAL
static bool test_reject_double_free(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
void *p = AllocatorAlloc(alloc, 32, false);
AllocatorFree(alloc, p); static bool test_reject_misaligned_pointer(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
u8 *p = (u8 *)AllocatorAlloc(alloc, 64, false);
AllocatorFree(alloc, p + 1); // mis-aligned -> LOG_FATAL
static bool test_reject_mid_xl_pointer(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
size n = 16 * 1024;
u8 *p = (u8 *)AllocatorAlloc(alloc, n, false);- In
Dns.Leak.c:34:
bool test_leak_record_target_freed(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
// header: id=0x0042 flags=0x8180 qd=1 an=1
- In
Dns.Leak.c:108:
bool test_leak_authority_list_freed(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 wire[64];- In
Dns.Leak.c:136:
bool test_leak_additional_list_freed(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 wire[64];- In
Io.Blind.c:674:
static bool test_float_sci_exponent_sign(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", ab);- In
Io.Blind.c:698:
static bool test_float_sci_exponent_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", ab);- In
Io.Blind.c:713:
static bool test_float_sci_single_digit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("2.0", ab);- In
Io.Blind.c:739:
static bool test_float_decimal_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("3.14159", ab);- In
Io.Blind.c:758:
static bool test_float_decimal_int_with_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("5", ab);- In
Io.Blind.c:782:
static bool test_float_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);- In
Io.Blind.c:801:
static bool test_float_width_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);- In
Io.Blind.c:822:
static bool read_float_is(Zstr in, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Float f = FloatInit(ab);
(void)FloatTryFromStr(&f, "99"); // sentinel
- In
Io.Blind.c:1134:
static bool test_bitvec_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("101", ab);- In
Io.Blind.c:1163:
static bool test_int_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Int v = IntFrom(42, ab); static bool test_basic_bump(void) {
ArenaAllocator arena = ArenaAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&arena);
u8 *a = (u8 *)AllocatorAlloc(alloc_base, 16, true);
u8 *b = (u8 *)AllocatorAlloc(alloc_base, 32, true); static bool test_grow_last_in_place(void) {
ArenaAllocator arena = ArenaAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&arena);
u8 *p = (u8 *)AllocatorAlloc(alloc_base, 16, true);
bool ok = (p != NULL); // is a caller bug and aborts via LOG_FATAL.
ArenaAllocator arena = ArenaAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&arena);
u8 *a = (u8 *)AllocatorAlloc(alloc_base, 16, true);
u8 *b = (u8 *)AllocatorAlloc(alloc_base, 16, true); // Free of a pointer not in any arena chunk is a caller bug.
ArenaAllocator arena = ArenaAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&arena);
char stack_byte = 0;
AllocatorFree(alloc_base, &stack_byte); // -> LOG_FATAL
static bool test_reset(void) {
ArenaAllocator arena = ArenaAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&arena);
u8 *a = (u8 *)AllocatorAlloc(alloc_base, 4096, true);
u8 *b = (u8 *)AllocatorAlloc(alloc_base, 4096, true); static bool test_alignment(void) {
ArenaAllocator arena = ArenaAllocatorInitAligned(64);
Allocator *alloc_base = ALLOCATOR_OF(&arena);
void *a = AllocatorAlloc(alloc_base, 1, true);
void *b = AllocatorAlloc(alloc_base, 1, true); static bool test_sd2_norm_mixed_case(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("WWW.Example.COM", "www.example.com", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_trailing_dot(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("Host.", "host", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_multi_trailing_dot(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("foo...", "foo", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_interior_dots_kept(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("a.b.c.", "a.b.c", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_digits_hyphens(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("Host-01.Net-2", "host-01.net-2", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_at_kept(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("a@Z", "a@z", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_bracket_kept(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("A[Z", "a[z", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_Z_lowered(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
bool ok = sd2_norm_eq("Z", "z", ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return ok; static bool test_sd2_norm_no_dot_len(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&alloc));
normalize_hostname("abc", &out);
bool ok = StrLen(&out) == 3 && ZstrCompare(StrBegin(&out), "abc") == 0; static bool test_sd2_norm_all_dots_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&alloc));
normalize_hostname("...", &out);
bool ok = StrLen(&out) == 0; static bool test_sd2_norm_null(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&alloc));
normalize_hostname(NULL, &out);
bool ok = StrLen(&out) == 0; static bool test_sd2_resolv_basic(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_v6(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_hash_comment_skipped(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_semicolon_comment_skipped(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_search_not_ns(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_keyword_needs_sep(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_tab_sep(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_leading_space(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_bad_ip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_trailing_comment(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_empty_ip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_order(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); static bool test_sd2_resolv_no_trailing_newline(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsAddrs out = VecInitT(out, a); WriteFmt("Testing BitVecShrinkToFit\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
WriteFmt("Testing BitVecReserve\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some bits
WriteFmt("Testing BitVecSwap\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up first bitvector
WriteFmt("Testing BitVecClone\n");
BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
// Set up original bitvector
alloc.base.retry_limit = 9;
BitVec original = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&original, true); WriteFmt("Testing BitVecShrinkToFit edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReserve edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecSwap edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecClone edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
for (int cycle = 0; cycle < 10; cycle++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc)); for (int cycle = 0; cycle < 10; cycle++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Add random-sized data
WriteFmt("Testing BitVec swap NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
WriteFmt("Testing resize-grow clears stale tail bits\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Fill a full byte with ones so bits 5,6,7 are set in the backing byte.
WriteFmt("Testing BitVecReserve with zero capacity returns true\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = (BitVecReserve(&bv, 0) == true); WriteFmt("Testing BitVecShrinkToFit preserves bits on a large vector\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// 400 bits => doubling growth yields capacity 512, byte_size 64,
WriteFmt("Testing BitVecShrinkToFit keeps the vector structurally valid\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 400; i++) { WriteFmt("Testing BitVecSwap keeps a swapped-in large vector valid\n");
BitVec small = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec small = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&small, true); WriteFmt("Testing BitVecSwap aborts on an invalid second argument\n");
BitVec good = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&good, true); WriteFmt("Testing BitVecTryClone aborts on an invalid source\n");
BitVec out = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; // magic 0 => invalid bitvec
- In
AllocDebug.c:31:
bool test_debug_normal_alloc_free(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p1 = AllocatorAlloc(adbg, 64, true);- In
AllocDebug.c:55:
bool test_debug_zero_byte_alloc(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 0, false);- In
AllocDebug.c:66:
bool test_debug_null_free_is_noop(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
AllocatorFree(adbg, NULL); // no-op, must not crash
- In
AllocDebug.c:83:
bool test_debug_catches_overflow(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 *buf = (u8 *)AllocatorAlloc(adbg, 16, true);- In
AllocDebug.c:99:
bool test_debug_leak_count(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
(void)AllocatorAlloc(adbg, 32, true);- In
AllocDebug.c:113:
bool test_debug_report_leaks_emits_traces(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p1 = AllocatorAlloc(adbg, 24, true);- In
AllocDebug.c:147:
bool test_debug_alloc_trace_captured(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 64, false);- In
AllocDebug.c:169:
bool test_debug_freed_history_grows_on_free(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
bool ok = (DebugAllocatorFreedCount(&dbg) == 0);- In
AllocDebug.c:201:
cfg.track_freed_history = false;
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
bool ok = true;- In
AllocDebug.c:224:
bool test_debug_remap_grows(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 *p = (u8 *)AllocatorAlloc(adbg, 16, true);- In
AllocDebug.c:246:
bool test_debug_remap_to_zero_frees(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 24, false);- In
AllocDebug.c:259:
bool test_debug_remap_from_null_allocates(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorRealloc(adbg, NULL, 32);- In
AllocDebug.c:277:
cfg.force_page_backing = true;
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 64, true);- In
AllocDebug.c:296:
bool test_debug_double_free_aborts(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, true);- In
AllocDebug.c:309:
// foreign pointer.
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 junk[64];- In
AllocDebug.c:332:
bool test_ad1_canary_detects_non_first_byte(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 *buf = (u8 *)AllocatorAlloc(adbg, 16, true);- In
AllocDebug.c:368:
bool test_ad1_freed_alloc_trace_n_copied(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 48, false);- In
AllocDebug.c:394:
bool test_ad1_freed_alloc_trace_bytes_copied(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 48, false);- In
AllocDebug.c:431:
cfg.capture_traces = false;
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, false);- In
AllocDebug.c:457:
cfg.trace_depth = 2;
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, false);- In
AllocDebug.c:482:
cfg.trace_depth = 20;
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, false);- In
AllocDebug.c:502:
bool test_ad1_stats_deallocations_increment(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, false);- In
AllocDebug.c:523:
bool test_ad1_stats_bytes_in_use_partial_free(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *a = AllocatorAlloc(adbg, 64, false);- In
AllocDebug.c:546:
bool test_ad1_clean_roundtrip_no_false_overflow(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 *buf = (u8 *)AllocatorAlloc(adbg, 32, false);- In
AllocDebug.c:567:
bool test_ad1_double_free_aborts(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, true);- In
AllocDebug.c:580:
bool test_ad1_foreign_free_aborts(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 junk[64];- In
AllocDebug.c:611:
bool test_ad2_alloc_bumps_live_bytes(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 100, false);- In
AllocDebug.c:630:
bool test_ad2_alloc_increments_allocations(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p1 = AllocatorAlloc(adbg, 16, false);- In
AllocDebug.c:649:
bool test_ad2_alloc_accumulates_bytes_requested(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p1 = AllocatorAlloc(adbg, 30, false);- In
AllocDebug.c:671:
bool test_ad2_alloc_bumps_stats_bytes_in_use(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 256, false);- In
AllocDebug.c:688:
bool test_ad2_alloc_tracks_peak_value(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 512, false);- In
AllocDebug.c:710:
bool test_ad2_peak_advances_on_first_alloc(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 333, false);- In
AllocDebug.c:729:
bool test_ad2_peak_holds_historical_max(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *big = AllocatorAlloc(adbg, 1000, false);- In
AllocDebug.c:755:
bool test_ad2_failed_alloc_counter(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
// Absurd size: the heap cannot serve it and returns NULL.
- In
AllocDebug.c:779:
bool test_ad2_trace_count_within_bounds(void) {
DebugAllocator dbg = DebugAllocatorInit(); // capture_traces, trace_depth=8
Allocator *adbg = ALLOCATOR_OF(&dbg);
// 30 levels of recursion guarantee the stack is deeper than the
- In
AllocDebug.c:804:
cfg.trace_depth = 4; // below MAX_TRACE
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = deep_alloc(adbg, 64, false, 30);- In
AllocDebug.c:830:
cfg.trace_depth = 32; // above MAX_TRACE -> must clamp to 16
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = deep_alloc(adbg, 64, false, 40);- In
AllocDebug.c:855:
bool test_ad2_full_width_write_is_clean(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
size n = 48;- In
AllocDebug.c:874:
bool test_ad2_zeroed_region_is_zero_and_sized(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
size n = 200;- In
AllocDebug.c:901:
bool test_ad2_hash_tracks_many_allocations(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
enum {- In
AllocDebug.c:945:
bool test_ad2_resize_refuses_in_place(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 64, false);- In
AllocDebug.c:974:
bool test_ad2_overflow_one_past_detected(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
size n = 32;- In
AllocDebug.c:995:
bool test_ad2_resize_validates_self(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 16, false); bool test_ad3_remap_grow_preserves_full_old_width(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 *p = (u8 *)AllocatorAlloc(adbg, 64, true); bool test_ad3_remap_shrink_copy_is_min_not_max(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 *p = (u8 *)AllocatorAlloc(adbg, 64, true); bool test_ad3_remap_unknown_ptr_aborts(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
u8 junk[64]; bool test_ad3_report_leaks_includes_trace_frames(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 24, true); // point; the validated bit is still set, so structural runs.
dbg.heap.base.__magic = 0xdeadbeefULL;
Allocator *adbg = ALLOCATOR_OF(&dbg);
(void)AllocatorAlloc(adbg, 32, true); // structural -> bad heap magic LOG_FATAL
return false; // unreachable
bool test_ad3_structural_skipped_after_first_op(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
// First op clears the validated bit.
// entry runs structural and exercises the pow2 check.
dbg.base.alignment = 4;
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 32, true); // real: 4 is pow2 -> accepted
bool test_ad3_structural_allows_live_allocation(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 48, true); // count=1, bytes_in_use=48
// self->page, so only structural can catch this.
dbg.page.base.__magic = 0xdeadbeefULL;
Allocator *adbg = ALLOCATOR_OF(&dbg);
(void)AllocatorAlloc(adbg, 32, true); // structural -> bad page magic LOG_FATAL
return false; // unreachable
cfg.trace_depth = 32; // above DEBUG_ALLOCATOR_MAX_TRACE (16)
DebugAllocator dbg = DebugAllocatorInitWith(cfg);
Allocator *adbg = ALLOCATOR_OF(&dbg);
af_deep_free(adbg, 25); // alloc+free ~25 frames deep
- In
Backtrace.c:30:
bool test_backtrace_format_resolves_helper(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
StackFrame frames[32];- In
Backtrace.c:71:
bool test_backtrace_vec_form_resolves_helper(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
StackFrames frames = VecInitT(frames, alloc_base);- In
Backtrace.c:96:
bool test_backtrace_format_with_shared_resolver(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
SymbolResolver res;- In
Backtrace.c:136:
bool test_backtrace_cfi_walks_multi_frame(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
SymbolResolver res;- In
Backtrace.c:187:
bool test_backtrace_cfi_agrees_with_fp(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
SymbolResolver res; WriteFmt("Testing BitVecForeachIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false
WriteFmt("Testing BitVecForeach macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true
WriteFmt("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false
WriteFmt("Testing BitVecForeachReverse macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true
WriteFmt("Testing BitVecForeachInRangeIdx macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: true, false, true, false, true
WriteFmt("Testing BitVecForeachInRange macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add test pattern: false, true, true, false, true
WriteFmt("Testing BitVec foreach edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
int count = 0; WriteFmt("Testing BitVec foreach idx edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
u64 last_idx = SIZE_MAX; WriteFmt("Testing BitVec foreach reverse edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec foreach range edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
for (int sz = 0; sz < 100; sz += 10) {
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create bitvec of varying sz
WriteFmt("Testing BitVecRunLengths basic functionality\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; bool test_bitvec_run_lengths_vec(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecRunLengths Vec form\n");
// Test 1: Empty bitvector
BitVec empty_bv = BitVecInit(ALLOCATOR_OF(&alloc));
u64 runs[5];
bool values[5];
// Test 2: Single bit (true)
BitVec single_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&single_bv, true);
count = BitVecRunLengths(&single_bv, runs, values, 5);
// Test 3: Single bit (false)
BitVec single_false_bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&single_false_bv, false);
count = BitVecRunLengths(&single_false_bv, runs, values, 5);
// Test 4: All same bits (all true)
BitVec all_true_bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 10; i++) {
BitVecPush(&all_true_bv, true);
// Test 5: Alternating bits (0101010)
BitVec alternating_bv = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 7; i++) {
BitVecPush(&alternating_bv, i % 2 == 0); WriteFmt("Testing BitVecRunLengths boundary conditions\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test with large bitvector
BitVec large_bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Create pattern that results in many runs
- In
Pdb.c:97:
bool test_pdb_parses_minimal_msf(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_msf_blob();- In
Pdb.c:122:
bool test_pdb_rejects_bad_magic(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 garbage[256];- In
Pdb.c:285:
bool test_pdb_extracts_pub32_function_name(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_full_pdb_blob();- In
Pdb.c:430:
bool test_pdb_resolves_among_multiple_functions(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 symrec_size = 0;- In
Pdb.c:488:
bool test_pdb_rejects_bad_block_size(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[256];- In
Pdb.c:511:
bool test_pdb_rejects_truncated_superblock(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[16];- In
Pdb.c:718:
bool test_pd1_substream_sum_locates_optdbg(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
DbiParams p = baseline_params();- In
Pdb.c:736:
bool test_pd1_symrec_index_drives_publics(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
DbiParams p = baseline_params();- In
Pdb.c:763:
bool test_pd1_optdbg_overrun_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
DbiParams p = {0};- In
Pdb.c:790:
bool test_pd1_sechdr_offset_bound_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
DbiParams p = {0};- In
Pdb.c:818:
bool test_pd1_sechdr_index_high_byte_oob(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
DbiParams p = baseline_params();- In
Pdb.c:972:
static bool test_pd2_superblock_fields_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[3] = {0, 28, 64};- In
Pdb.c:995:
static bool open_with_block_size(u32 bs) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[2] = {0, 28};
u32 blob_len = build_blob_m2(bs, sizes, 2, NULL, NULL);- In
Pdb.c:1025:
static bool test_pd2_block_size_256_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[256];- In
Pdb.c:1049:
static bool test_pd2_magic_each_byte_matters(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[2] = {0, 28};- In
Pdb.c:1073:
static bool test_pd2_truncated_below_superblock_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[55]; // one short of the 56-byte superblock
- In
Pdb.c:1093:
static bool test_pd2_dir_block_id_one_past_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[2] = {0, 28};- In
Pdb.c:1114:
static bool test_pd2_last_block_in_bounds_opens(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[2] = {0, 28};- In
Pdb.c:1135:
static bool test_pd2_dir_stream_blocks_count_one(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[2] = {0, 28};- In
Pdb.c:1220:
static bool test_pd2_two_block_directory(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_two_block_dir();- In
Pdb.c:1247:
static bool test_pd2_stream_metadata_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Stream 2 spans 3 blocks (size in (2*512, 3*512]); stream 3 is NIL.
- In
Pdb.c:1284:
static bool test_pd2_multiblock_block_list_contiguous(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// stream 1 -> 2 blocks, stream 2 -> 1 block.
- In
Pdb.c:1312:
static bool test_pd2_single_stream(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u32 sizes[1] = {28};- In
Pdb.c:1334:
static bool test_pd2_truncated_sizes_table_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Build a normal 2-stream blob, then overwrite the directory's
- In
Pdb.c:1354:
static bool test_pd2_truncated_blockid_table_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Normal 2-stream blob: stream 1 size 28 -> 1 block. Inflate stream
- In
Pdb.c:1376:
static bool test_pd2_zero_streams_dir_exactly_4(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Hand-build: superblock + block-map(->dir page) + dir page holding
- In
Pdb.c:1415:
static bool test_pd2_sizes_table_exact_fit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// 3 streams, all empty/NIL -> total_blocks 0 -> dir_bytes = 4+12 = 16
- In
Pdb.c:1444:
static bool test_pd2_blockwords_exceed_expected_opens(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// sizes: stream 0 empty, stream 1 = 2000 bytes -> ceil(2000/512) = 4
- In
Pdb.c:1482:
static bool test_pd2_dir_blockmap_fills_one_page(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
MemSet(g_hblob, 0, sizeof(g_hblob));- In
Pdb.c:1670:
bool test_pd3_filter_and_count(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_filter_blob();- In
Pdb.c:1731:
bool test_pd3_section_indexing(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_sect_blob();- In
Pdb.c:1788:
bool test_pd3_out_of_range_segment_dropped(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_oob_seg_blob();- In
Pdb.c:1844:
bool test_pd3_function_sizes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_size_blob();- In
Pdb.c:1911:
bool test_pd3_sort_ascending(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_sort_blob();- In
Pdb.c:1972:
bool test_pd3_malformed_records(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_mal_blob();- In
Pdb.c:2030:
bool test_pd3_rva_overflow_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_ovf_blob();- In
Pdb.c:2224:
bool test_pd4_crossblock_straddling_function(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_crossblock_blob();- In
Pdb.c:2261:
bool test_pd4_info_fields_decoded_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_crossblock_blob();- In
Pdb.c:2338:
bool test_pd4_info_read_failure_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Point stream #1 at page 999 -- far past EOF -> block_ptr NULL ->
- In
Pdb.c:2360:
bool test_pd4_info_blob_opens_when_valid(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_info_blob(S_INFO_PAGE);- In
Pdb.c:2386:
bool test_pd4_failed_open_frees_all(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
// Blob that parses superblock + directory (allocating stream_dir and
- In
Pdb.c:2425:
bool test_pd4_deinit_frees_name_pool(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
build_crossblock_blob(); // populates name_pool with two function names
- In
Pdb.c:2460:
bool test_pd4_open_valid_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_crossblock_blob();- In
Pdb.c:2487:
bool test_pd4_open_valid_path_junk_content(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 junk[256];- In
Pdb.c:2508:
bool test_pd4_resolve_first_and_below(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_crossblock_blob();- In
Pdb.c:2674:
bool test_pf_multi_section_last_segment_rva(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecSpec secs[6];- In
Pdb.c:2708:
bool test_pf_section_stream_read_failure_yields_no_functions(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecSpec secs[3] = {- In
Pdb.c:2739:
bool test_pf_rva_overflow_skip_advances_cursor(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecSpec secs[2] = {- In
Pdb.c:2771:
bool test_pf_function_sizes_from_next_rva(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecSpec secs[1] = {- In
Pdb.c:2804:
bool test_pf_named_public_accepted(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecSpec secs[1] = {- In
Pdb.c:2838:
bool test_pf_walk_publics_failure_propagates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecSpec secs[1] = {- In
Str.Init.c:311:
WriteFmt("Testing StrDeinit releases the backing allocation\n");
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
Str s = StrInitFromZstr("hello world", adbg);- In
Dns.Blind.c:32:
static bool test_blind_question_name_fail_no_leak(void) {
DebugAllocator dbg = make_lean_dbg();
Allocator *a = ALLOCATOR_OF(&dbg);
// header: qd=1 an=0; question name [10]"abcdefghij" then a 20-len label
- In
Dns.Blind.c:54:
static bool test_blind_record_decode_fail_no_leak(void) {
DebugAllocator dbg = make_lean_dbg();
Allocator *a = ALLOCATOR_OF(&dbg);
// header: qd=0 an=1; answer name [10]"abcdefghij"+root, type=A class=IN
- In
Dns.Blind.c:81:
static bool test_blind_pointer_truncated_rejected(void) {
DebugAllocator dbg = make_lean_dbg();
Allocator *a = ALLOCATOR_OF(&dbg);
// header(12) then a lone 0xC0 pointer lead byte at EOF (no 2nd byte).
- In
Dns.Blind.c:204:
static bool test_blind_hops_max_boundary(void) {
DebugAllocator dbg = make_lean_dbg();
Allocator *a = ALLOCATOR_OF(&dbg);
u8 wire[4096]; WriteFmt("Testing BitVecEquals\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test equal empty bitvectors
WriteFmt("Testing BitVecCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test equal bitvectors
WriteFmt("Testing BitVecLexCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test lexicographic comparison
WriteFmt("Testing BitVecNumericalCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create bitvectors representing different numbers
WriteFmt("Testing BitVecWeightCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1: 111 (3 ones)
WriteFmt("Testing BitVecIsSubset\n");
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create superset: 1111
WriteFmt("Testing BitVecSignedCompare\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test positive vs negative (MSB is sign bit)
WriteFmt("Testing BitVecIsSuperset\n");
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create superset: 1111
WriteFmt("Testing BitVecOverlaps\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create overlapping bitvectors
WriteFmt("Testing BitVecDisjoint and BitVecIntersects\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create disjoint bitvectors
WriteFmt("Testing BitVecEqualsRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create test patterns
WriteFmt("Testing BitVecCompareRange\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create test patterns
WriteFmt("Testing BitVecIsLexicographicallyLess and BitVecIsNumericallyLess\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test lexicographic comparison
WriteFmt("Testing BitVecIsSorted\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test empty bitvector (should be sorted)
WriteFmt("Testing BitVec compare edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec set operations edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec comprehensive comparison operations\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test transitivity: if A < B and B < C, then A < C
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv3: larger than bv2
for (int i = 0; i < 8; i++) {
// Test subset/superset consistency
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc)); // Test subset/superset consistency
BitVec subset = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec superset = BitVecInit(ALLOCATOR_OF(&alloc));
// Create actual subset/superset relationship
WriteFmt("Testing BitVec large-scale comparison operations\n");
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec large1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec large2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Verify signed vs unsigned comparison differences
BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc)); // Verify signed vs unsigned comparison differences
BitVec pos = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec neg = BitVecInit(ALLOCATOR_OF(&alloc));
// Positive number (MSB = 0): 01111111
WriteFmt("Testing BitVec compare NULL pointer handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
WriteFmt("Testing BitVec range operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer in range operations - should abort
WriteFmt("Testing BitVec range operations bounds checking\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Create small bitvectors
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base);
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Map(BitVec, u64) counts = MapInit(bitvec_hash, bitvec_compare, &alloc);
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); WriteFmt("Testing BitVecEquals rejects bad second operand\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; WriteFmt("Testing BitVecEqualsRange rejects bad second operand\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; static bool test_hash_xor_byte_distinguishes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); // byte 0x00
static bool test_hash_length_mix_mul_distinguishes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); // 10101010
static bool test_hash_all_bytes_folded(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); // byte0 = 0xFF, byte1 = 0x00
static bool test_compare_null_lhs_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_compare_null_rhs_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_compare_range_null_lhs_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_compare_range_null_rhs_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_numerical_compare_null_lhs_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_numerical_high_bit_not_truncated(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv1 = BitVecInit(base); static bool test_signed_neg_vs_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec neg = BitVecInit(base); static bool test_signed_empty_vs_neg(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec empty = BitVecInit(base); static bool test_signed_sign1_le_mutant(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec neg = BitVecInit(base); static bool test_signed_sign1_ge_no_abort(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec empty = BitVecInit(base); static bool test_signed_sign2_ge_no_abort(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec neg = BitVecInit(base); static bool test_signed_two_equal_negatives(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); static bool test_signed_two_negatives_magnitude_flip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec a = BitVecInit(base); static bool test_numerical_null_bv2(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_signed_null_bv1(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_signed_null_bv2(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); static bool test_subset_null_bv1(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); bool test_subset_skips_high_positions(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecIsSubset scans past index 42\n"); bool test_subset_bv1_short_no_abort(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecIsSubset with shorter bv1 stays in bounds\n"); bool test_subset_bv2_short_no_abort(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecIsSubset with shorter bv2 stays in bounds\n"); bool test_disjoint_scans_all_positions(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecDisjoint scans beyond position 0\n"); bool test_subset_null_bv2_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecIsSubset rejects NULL bv2\n"); bool test_disjoint_null_bv1_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecDisjoint rejects NULL bv1\n"); bool test_disjoint_null_bv2_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecDisjoint rejects NULL bv2\n");- In
SysDns.c:14:
static bool test_dns_resolve_localhost_from_hosts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:46:
static bool test_dns_resolve_hosts_case_insensitive(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:64:
static bool test_dns_resolve_hosts_trailing_dot(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:83:
static bool test_dns_resolve_spec_numeric_v4(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:107:
static bool test_dns_resolve_spec_numeric_v6(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:132:
static bool test_dns_resolve_spec_hostname(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:163:
static bool test_dns_resolve_spec_single_addr(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:186:
static bool test_dns_resolve_spec_no_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.c:205:
static bool test_dns_resolve_spec_bad_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
Int.Leak.c:35:
bool test_mul_nonzero_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(123456u, a);- In
Int.Leak.c:54:
bool test_mul_zero_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(0u, a);- In
Int.Leak.c:73:
bool test_add_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(0xFFFFFFFFull, a);- In
Int.Leak.c:92:
bool test_sub_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(1000000u, a);- In
Int.Leak.c:111:
bool test_add_u64_in_place_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// IntAdd with a u64 operand drives int_add_u64 -> int_add_u64_in_place,
- In
Int.Leak.c:130:
bool test_mul_u64_in_place_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// IntMul with a u64 operand drives int_mul_u64 -> int_mul_u64_in_place,
- In
Int.Leak.c:149:
bool test_sub_u64_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(1000u, a);- In
Int.Leak.c:170:
bool test_div_mod_ge_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// dividend >= divisor drives the long-division branch (lines 1378..1411,
- In
Int.Leak.c:193:
bool test_div_mod_lt_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// dividend < divisor drives the else branch (line 1413: deinit+reinit q).
- In
Int.Leak.c:215:
bool test_div_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1000003u, a);- In
Int.Leak.c:234:
bool test_div_exact_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1000u, a);- In
Int.Leak.c:253:
bool test_div_scalar_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// int_div_u64 / int_div_exact_u64 / int_div_i64 etc. free divisor_value
- In
Int.Leak.c:278:
bool test_div_mod_scalar_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// int_div_mod_u64 / int_div_mod_i64 free divisor_value on success
- In
Int.Leak.c:306:
bool test_mod_int_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1003u, a);- In
Int.Leak.c:329:
bool test_to_str_radix_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Drives int_try_to_str_radix loop (760, 772) and int_div_u64_rem
- In
Int.Leak.c:358:
bool test_pow_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// exponent 13 = 0b1101 hits both the multiply-acc branch (1317) and the
- In
Int.Leak.c:381:
bool test_gcd_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Euclid loop frees x each iteration (1657), final y cleanup (1663).
- In
Int.Leak.c:401:
bool test_lcm_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Success path frees gcd + quotient (1689/1690).
- In
Int.Leak.c:425:
bool test_root_rem_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Non-trivial cube root drives the bisection loop: low/high/mid/mid_pow
- In
Int.Leak.c:446:
bool test_root_rem_inexact_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Inexact root exercises the cmp>0 branch (1819/1822/1832 high update).
- In
Int.Leak.c:472:
bool test_root_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int v = IntFrom(1000000u, a);- In
Int.Leak.c:489:
bool test_is_perfect_square_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Frees root + remainder on success (1904/1905).
- In
Int.Leak.c:506:
bool test_is_perfect_power_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Loop frees root + remainder each degree (1934/1935).
- In
Int.Leak.c:527:
bool test_jacobi_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Drives the main loop (swap, even-stripping 1972, inner deinits) and both
- In
Int.Leak.c:558:
bool test_mod_add_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(12345u, a);- In
Int.Leak.c:579:
bool test_mod_sub_ge_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// ar >= br branch (2098/2099 frees ar/br).
- In
Int.Leak.c:601:
bool test_mod_sub_lt_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// ar < br branch: nonzero diff -> modulus-diff (2095 frees diff).
- In
Int.Leak.c:623:
bool test_mod_sub_zero_diff_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// ar < br but diff is a multiple of modulus -> diff==0 inner branch
- In
Int.Leak.c:650:
bool test_mod_mul_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(12345u, a);- In
Int.Leak.c:671:
bool test_square_mod_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(12345u, a);- In
Int.Leak.c:690:
bool test_mod_div_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// IntModDiv frees inverse on success (2160).
- In
Int.Leak.c:711:
bool test_pow_u64_mod_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// int_pow_u64_mod: multiply-acc (2201) and square (2215), final cleanup
- In
Int.Leak.c:732:
bool test_pow_mod_integer_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// int_pow_mod (Int exponent) main loop + final base_mod/exp cleanup.
- In
Int.Leak.c:759:
bool test_mod_inv_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int v = IntFrom(17u, a);- In
Int.Leak.c:778:
bool test_mod_inv_negative_t_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// A case where the Bezout coefficient t is negative, driving the
- In
Int.Leak.c:800:
bool test_mod_inv_no_solution_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// gcd != 1 -> r != one, the if(IntEQ(&r,&one)) block is skipped and ok stays
- In
Int.Leak.c:826:
bool test_mod_sqrt_p3mod4_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// modulus 7 (7 % 4 == 3) drives the fast path: frees exponent + a (2488/2489).
- In
Int.Leak.c:847:
bool test_mod_sqrt_tonelli_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// modulus 17 (17 % 4 == 1) drives the Tonelli-Shanks block: q/z/c/t/r,
- In
Int.Leak.c:870:
bool test_mod_sqrt_tonelli_larger_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// modulus 41 (41 % 4 == 1, 41-1 = 40 = 8*5 so m=3 levels) drives the inner
- In
Int.Leak.c:892:
bool test_mod_sqrt_zero_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// value % modulus == 0 -> zero branch frees a (2449).
- In
Int.Leak.c:911:
bool test_mod_sqrt_mod2_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// modulus 2 path: int_replace(result, &a) (no extra deinit, but reaches
- In
Int.Leak.c:931:
bool test_mod_sqrt_no_solution_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// jacobi != 1 -> non-residue, frees a and returns false (2473's deinit at
- In
Int.Leak.c:951:
bool test_mod_sqrt_composite_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// composite (non-prime) odd modulus -> !prime branch frees a (2465).
- In
Int.Leak.c:970:
bool test_mod_sqrt_even_modulus_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// even modulus (>2) -> IntIsEven branch frees a (2465).
- In
Int.Leak.c:993:
bool test_is_probable_prime_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Large-ish prime drives the full Miller-Rabin loop: base/x deinits in the
- In
Int.Leak.c:1013:
bool test_is_probable_prime_witness_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// A strong-pseudoprime-ish composite that forces the witness inner loop
- In
Int.Leak.c:1030:
bool test_next_prime_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// Drives candidate-stepping loop (frees candidate on success at 2924, and
- In
Int.Leak.c:1049:
bool test_next_prime_small_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// value <= 1 -> two path (2879 int_replace) and the candidate<=2 path
- In
Int.Leak.c:1100:
bool test_from_str_nonempty_out_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int out = IntFrom(987654321u, a); // pre-populated: holds a live buffer
- In
Int.Leak.c:1118:
bool test_mul_nonzero_nonempty_result_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(123456u, a);- In
Int.Leak.c:1140:
bool test_div_exact_i64_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1000u, a);- In
Int.Leak.c:1161:
bool test_mod_sqrt_tonelli_inner_loop_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *a = ALLOCATOR_OF(&dbg);
// moduli with p % 4 == 1 (forces the Tonelli-Shanks block) and a high power
- In
BitVec.Leak.c:26:
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
BitVec bv = BitVecInit(adbg); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = float_from_u64(42, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = float_from_i64(-42, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Int integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
Float value = float_from_int(&integer, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
Int integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
Float value = float_from_int(&integer, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc)); Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));
bool result = FloatToInt(&result_value, &value); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("123.45", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
Float value = FloatFromStr("123.45", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
bool result = !FloatToInt(&result_value, &value); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("-42", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
Float value = FloatFromStr("-42", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
bool result = !FloatToInt(&result_value, &value); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value); alloc.base.retry_limit = 5;
Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
ok = float_try_to_str(&text, &value, ALLOCATOR_OF(&alloc)); Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
ok = float_try_to_str(&text, &value, ALLOCATOR_OF(&alloc));
bool result = ok && (ZstrCompare(StrBegin(&text), "-123.45") == 0) && DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("1.2300e3", ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Float parsed = FloatFromStr("12.3.4", ALLOCATOR_OF(&alloc));
Float value = FloatInit(ALLOCATOR_OF(&alloc));
bool result = !FloatTryFromStr(&value, "12.3.4");
Float parsed = FloatFromStr("12.3.4", ALLOCATOR_OF(&alloc));
Float value = FloatInit(ALLOCATOR_OF(&alloc));
bool result = !FloatTryFromStr(&value, "12.3.4"); DefaultAllocator alloc = DefaultAllocatorInit();
FloatFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false; DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatInit(ALLOCATOR_OF(&alloc));
FloatTryFromStr(&value, (Zstr)NULL);
FloatDeinit(&value); static bool resolve_through_stripped(void (*func)(void), Zstr expect_name) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// (1) Find this process's load base for /proc/self/exe.
WriteFmt("Testing BitVec bitwise operations NULL handling\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL pointer - should abort
WriteFmt("Testing BitVec AND with NULL result handling\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecPush(&bv2, false); WriteFmt("Testing BitVec OR with NULL operand handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL operand - should abort
WriteFmt("Testing BitVec XOR with NULL second operand handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL second operand - should abort
WriteFmt("Testing BitVec NOT with NULL handling\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
// Test NULL operand - should abort
WriteFmt("Testing BitVecAnd rejects bad third operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; WriteFmt("Testing BitVecAnd rejects bad second operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; WriteFmt("Testing BitVecOr rejects bad second operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec b = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; WriteFmt("Testing BitVecXor rejects bad third operand\n");
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0};
BitVec result = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; static bool test_pc_find_pdb_basename_fallback(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Fixture fx; static bool test_pc_find_pdb_missing_sidecar_rejected(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
char pe_path[1024]; static bool test_pc_find_pdb_no_dirname_boundary(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
// Bare names (no path separator), resolved relative to cwd.
static bool test_pc_entry_open_failure_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
char pe_path[1024]; static bool test_pc_entry_open_bad_pdb_fails(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
char pe_path[1024]; static bool test_pc_cache_hit_no_duplicate_entry(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Fixture fx; static bool test_pc_cache_hit_with_second_module(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Fixture fa, fb; static bool test_pc_deinit_frees_all_entries(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Fixture fx; static bool test_pc_resolve_correct_symbol(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Fixture fx; static bool test_pc_resolve_at_module_base_boundary(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
char pe_path[1024]; static bool test_pc_resolve_max_rva_boundary(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
char pe_path[1024]; static bool test_pc_resolve_str_matches_zstr(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Fixture fx; bool test_blind_stats_bytes_in_use_underflow_clamps_zero(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 64, false); bool test_blind_report_leaks_emits_all_frames(void) {
DebugAllocator dbg = DebugAllocatorInit(); // capture_traces on, depth 8
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 24, true); bool test_blind_report_leaks_no_extra_frame(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
void *p = AllocatorAlloc(adbg, 24, true);- In
Socket.c:20:
bool test_socket_loopback_round_trip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:93:
bool test_socket_addr_format_round_trip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
bool ok = true;- In
Socket.c:206:
bool test_sk1_read_ready_sets_read_flag(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p = pair_make(a);- In
Socket.c:241:
bool test_sk1_write_only_request_no_read_event(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p = pair_make(a);- In
Socket.c:275:
bool test_sk1_write_ready_sets_write_flag(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p = pair_make(a);- In
Socket.c:303:
bool test_sk1_read_only_request_no_write_event(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p = pair_make(a);- In
Socket.c:338:
bool test_sk1_timeout_returns_zero_no_flags(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p = pair_make(a);- In
Socket.c:373:
bool test_sk1_three_sockets_two_ready_count(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p0 = pair_make(a);- In
Socket.c:434:
bool test_sk1_middle_socket_ready_index(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p0 = pair_make(a);- In
Socket.c:485:
bool test_sk1_peer_close_reports_read_ready(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair p = pair_make(a);- In
Socket.c:540:
};
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair pairs[N];- In
Socket.c:583:
};
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Pair pairs[N];- In
Socket.c:641:
static bool fmt_eq(Zstr spec, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr addr;- In
Socket.c:777:
bool test_sk3_parse_ipv4_fields(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr addr;- In
Socket.c:797:
bool test_sk3_parse_ipv4_port_byteswap(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr addr;- In
Socket.c:815:
bool test_sk3_parse_ipv6_fields(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr addr;- In
Socket.c:842:
bool test_sk3_parse_ipv6_loopback(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr addr;- In
Socket.c:912:
bool test_sk3_listener_bound_fixed_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr bind_addr;- In
Socket.c:948:
bool test_sk3_listener_ephemeral_real_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr bind_addr;- In
Socket.c:988:
bool test_sk3_listener_accept_kind(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
SocketAddr bind_addr;- In
Socket.c:1150:
bool test_sk4_round_trip_both_directions(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1213:
bool test_sk4_recv_eof_on_peer_close(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1250:
bool test_sk4_local_addr_nonzero_port(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1290:
bool test_sk4_poll_read_ready(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1345:
bool test_sk4_recv_timeout_applies(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1389:
bool test_sk4_send_timeout_applies(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1426:
bool test_sk4_socket_options_apply(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Listener listener;- In
Socket.c:1474:
bool test_sk4_parse_port_boundaries(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
bool ok = true;- In
Socket.c:1537:
bool test_sk4_parse_str_overload_round_trip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
bool ok = true;- In
Socket.c:1571:
bool test_sk4_format_empty_and_ipv6(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
bool ok = true;- In
ProcMaps.c:17:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:45:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:73:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:95:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:124:
volatile int local = 0xABCD;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:153:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:192:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:236:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:258:
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
ProcMaps.c:308:
bool test_pm2_deinit_releases_all(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
size before = DebugAllocatorLiveCount(&dbg);- In
ProcMaps.c:340:
DefaultAllocator alloc = DefaultAllocatorInit();
ProcMaps maps;
if (!ProcMapsLoad(&maps, ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Http.c:13:
bool test_http_request_parse_get_with_headers(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr raw =- In
Http.c:39:
bool test_http_response_serialize_html(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);- In
Http.c:69:
bool test_http_request_parse_all_methods(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
struct {- In
Http.c:102:
bool test_http_request_parse_rejects_unknown_method(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr cases[] = {- In
Http.c:126:
bool test_http_request_method_length_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr cases[] = {- In
Http.c:153:
bool test_ht_header_count_cap_rejects_over_limit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str raw = StrInit(alloc_base);- In
Http.c:181:
bool test_ht_header_count_cap_accepts_at_limit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str raw = StrInit(alloc_base);- In
Http.c:209:
bool test_ht_respond_with_file_sets_fields(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path = StrInit(alloc_base);- In
Http.c:239:
bool test_ht_respond_with_file_empty_succeeds(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path = StrInit(alloc_base);- In
Http.c:265:
bool test_ht_respond_with_file_missing_fails(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);- In
BitVec.Mut.c:30:
DebugAllocator dbg = DebugAllocatorInitWith(lean_dbg_cfg());
Allocator *adbg = ALLOCATOR_OF(&dbg);
BitVec bv = BitVecInit(adbg);- In
BitVec.Mut.c:70:
DebugAllocator dbg = DebugAllocatorInitWith(lean_dbg_cfg());
Allocator *adbg = ALLOCATOR_OF(&dbg);
BitVec bv = BitVecInit(adbg);- In
BitVec.Mut.c:105:
DebugAllocator dbg = DebugAllocatorInitWith(lean_dbg_cfg());
Allocator *adbg = ALLOCATOR_OF(&dbg);
DefaultAllocator palloc = DefaultAllocatorInit();- In
BitVec.Mut.c:108:
DefaultAllocator palloc = DefaultAllocatorInit();
Allocator *pbase = ALLOCATOR_OF(&palloc);
BitVec bv = BitVecInit(adbg); bool test_bl_dwarf_resolves(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_bl_dwarf"; bool test_bl_dwarf_resolves_twice(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_bl_dwarf2"; bool test_bl_dwarf_resolves_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_bl_dwarf3";- In
Vec.Complex.c:26:
g_fixture_heap_ready = true;
}
return ALLOCATOR_OF(&g_fixture_heap);
} bool test_sd1_slurp_reads_full_content(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "abcdefghij0123456789Z"; // last byte 'Z'
bool test_sd1_slurp_multi_chunk(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
u64 n = 10000; bool test_sd1_slurp_empty_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *path = stage_hosts("", 0); bool test_sd1_slurp_missing_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Str out = StrInit(a); bool test_sd1_slurp_read_error_returns_false(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
Str out = StrInit(a); bool test_sd1_hosts_slurp_failure_empty_table(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
g_redirect_to = "/tmp"; // directory: open ok, read fails
bool test_sd1_hosts_single_v4(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "127.0.0.1 localhost\n"; bool test_sd1_hosts_aliases(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "192.168.1.5 host.example alias1 alias2 alias3\n"; bool test_sd1_hosts_comments_and_blanks(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = bool test_sd1_hosts_inline_comment(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "10.0.0.2 namex # trailing comment words\n"; bool test_sd1_hosts_leading_and_tab_whitespace(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = " \t 172.16.0.9\thostT\talT\n"; bool test_sd1_hosts_case_lowered(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "10.1.1.1 MixedCaseHost\n"; bool test_sd1_hosts_no_trailing_newline(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "10.0.0.1 a\n8.8.8.8 dns"; // no '\n' at EOF
bool test_sd1_hosts_multiline_no_desync(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = bool test_sd1_hosts_ipv6(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = "::1 ip6-localhost\n"; bool test_sd1_hosts_non_ip_line_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = bool test_sd1_hosts_ip_only_no_name(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = bool test_sd1_hosts_missing_yields_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
g_redirect_to = "/tmp/sd1_definitely_missing_zzqq2"; bool test_sd1_hosts_bare_ip_eof(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// First line bare IP + newline, last line a bare IP token that runs
bool test_sd1_hosts_overlong_first_token(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
// 70-char first token (>= 64) followed by a name, then a real entry.
bool test_sd1_hosts_reject_skips_rest_of_line(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
const char *body = static bool test_basic_alloc_and_free(void) {
PageAllocator alloc = PageAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
void *ptr = AllocatorAlloc(alloc_base, 128, true);
bool ok = (ptr != NULL); static bool test_realloc_grow_then_shrink(void) {
PageAllocator alloc = PageAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
size page = PageAllocatorPageSize(&alloc);
u8 *ptr = (u8 *)AllocatorAlloc(alloc_base, 64, true); // portably.
PageAllocator alloc = PageAllocatorInitAligned(64);
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
size page = PageAllocatorPageSize(&alloc);
void *ptr = AllocatorAlloc(alloc_base, 1024, true); bool ok = true;
PageAllocator alloc = PageAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
size page = PageAllocatorPageSize(&alloc);- In
MachoCache.c:179:
bool test_macho_cache_resolves_via_main_symtab(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_macho_main.bin";- In
MachoCache.c:208:
bool test_macho_cache_falls_through_to_dsym(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_macho_stripped";- In
MachoCache.c:249:
bool test_macho_cache_rejects_uuid_mismatch(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_macho_uuidmiss";- In
MachoCache.c:612:
bool test_mc_main_symtab_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_main.bin";- In
MachoCache.c:646:
bool test_mc_cache_hit_and_distinct(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_a = "/tmp/misra_mc_hit_a.bin";- In
MachoCache.c:703:
bool test_mc_dsym_symtab_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_dsym";- In
MachoCache.c:740:
bool test_mc_dsym_uuid_mismatch_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_uuidmiss";- In
MachoCache.c:781:
bool test_mc_dwarf_resolves_and_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_dwarf";- In
MachoCache.c:825:
bool test_mc_slide_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_mc_slide.bin";- In
MachoCache.c:858:
bool test_mc_resolve_str_delegates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_mc_str.bin";- In
Int.Blind.c:60:
bool test_blind_mod_inv_correct(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(7u, alloc);- In
Int.Blind.c:81:
bool test_blind_mod_sqrt_tonelli(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(9u, alloc);- In
Int.Blind.c:105:
bool test_blind_mod_sqrt_fast_branch(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(2u, alloc);- In
Int.Blind.c:129:
bool test_blind_mod_sub_branches(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int m = IntFrom(7u, alloc);- In
Int.Blind.c:161:
bool test_blind_next_prime(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(100u, alloc);- In
Int.Blind.c:180:
bool test_blind_carmichael_is_composite(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(561u, alloc);- In
Int.Blind.c:198:
bool test_blind_to_str_radix_big(void) {
DebugAllocator dbg = DebugAllocatorInitWith(blind_cfg());
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFromStr("123456789012345678901234567890", alloc);- In
MachO.Blind.c:49:
bool test_mhb_has_uuid_is_canonical_true(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
enum {- In
SysDns.Mut.c:123:
static bool test_sdm_hosts_v6_flag_true(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
HostsTable t = parse_hosts_crafted("fe80::1 v6host\n", a);- In
SysDns.Mut.c:148:
static bool test_sdm_hosts_v4_flag_false(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
HostsTable t = parse_hosts_crafted("10.20.30.40 v4host\n", a);- In
SysDns.Mut.c:172:
static bool test_sdm_resolv_buf_no_leak(void) {
DebugAllocator alloc = DebugAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
size baseline = DebugAllocatorLiveCount(&alloc);- In
SysDns.Mut.c:201:
static bool test_sdm_hosts_buf_no_leak(void) {
DebugAllocator alloc = DebugAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
size baseline = DebugAllocatorLiveCount(&alloc);- In
SysDns.Mut.c:265:
static bool test_sdm_resolve_one_hit_writes_addr(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
SysDns.Mut.c:282:
static bool test_sdm_resolve_one_miss_false(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);
DnsResolver r;- In
Pe.Blind.c:107:
static bool test_pe_blind_find_empty_name_returns_null(void) {
DebugAllocator alloc = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SecDesc secs[2];- In
BitVec.Math.c:81:
WriteFmt("Testing BitVecHammingDistance basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
BitVec.Math.c:82:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecHammingDistance edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecJaccardSimilarity basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecJaccardSimilarity edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCosineSimilarity basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCosineSimilarity edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecDotProduct basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecDotProduct edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEditDistance basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEditDistance edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCorrelation basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCorrelation edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEntropy basic functionality\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEntropy edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecAlignmentScore basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecAlignmentScore edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecBestAlignment basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecBestAlignment edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec Math stress tests\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
// Test edit distance with smaller vectors (expensive operation)
BitVec small1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec small2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 50; i++) { // Test edit distance with smaller vectors (expensive operation)
BitVec small1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec small2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 50; i++) {
BitVecPush(&small1, i % 2 == 0);
WriteFmt("Testing BitVecHammingDistance(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecHammingDistance(NULL, &bv2);
WriteFmt("Testing BitVecHammingDistance(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecHammingDistance(&bv1, NULL);
WriteFmt("Testing BitVecJaccardSimilarity(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecJaccardSimilarity(NULL, &bv2);
WriteFmt("Testing BitVecJaccardSimilarity(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecJaccardSimilarity(&bv1, NULL);
WriteFmt("Testing BitVecCosineSimilarity(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecCosineSimilarity(NULL, &bv2);
WriteFmt("Testing BitVecCosineSimilarity(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecCosineSimilarity(&bv1, NULL);
WriteFmt("Testing BitVecDotProduct(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecDotProduct(NULL, &bv2);
WriteFmt("Testing BitVecDotProduct(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecDotProduct(&bv1, NULL);
WriteFmt("Testing BitVecEditDistance(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecEditDistance(NULL, &bv2);
WriteFmt("Testing BitVecEditDistance(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecEditDistance(&bv1, NULL);
WriteFmt("Testing BitVecCorrelation(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecCorrelation(NULL, &bv2);
WriteFmt("Testing BitVecCorrelation(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecCorrelation(&bv1, NULL);
WriteFmt("Testing BitVecAlignmentScore(NULL, bv2, 1, -1) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecAlignmentScore(NULL, &bv2, 1, -1);
WriteFmt("Testing BitVecAlignmentScore(bv1, NULL, 1, -1) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecAlignmentScore(&bv1, NULL, 1, -1);
WriteFmt("Testing BitVecBestAlignment(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecBestAlignment(NULL, &bv2);
WriteFmt("Testing BitVecBestAlignment(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecBestAlignment(&bv1, NULL); WriteFmt("Testing BitVecJaccardSimilarity guard only fires when both empty\n");
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec one = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&one, true);
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec one = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&one, true); WriteFmt("Testing BitVecJaccardSimilarity with bv1 shorter than bv2\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1 = {1}, bv2 = {1, 0}. Intersection 1 (pos 0), union 1 -> 1.0.
WriteFmt("Testing BitVecJaccardSimilarity with bv2 shorter than bv1\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1 = {1, 0}, bv2 = {1}. Intersection 1 (pos 0), union 1 -> 1.0.
WriteFmt("Testing BitVecJaccardSimilarity reads bv2 bits in valid region\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
// bv1 = {0, 0}, bv2 = {1, 1}. Intersection 0, union 2 -> 0.0.
WriteFmt("Testing BitVecEditDistance column-0 base case\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, false); WriteFmt("Testing BitVecEditDistance deletion term\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, false); // exact size the empty->5 distance will recycle, guaranteeing the stale
// (large) values land in prev_row[len2].
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) { // (large) values land in prev_row[len2].
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {
BitVecPush(&warm_a, (i % 2) == 0); BitVecDeinit(&warm_b);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 5; i++) {
BitVecPush(&bv2, true); // the empty->4 distance recycles, so the unfilled prev_row[len2] holds a
// stale large value rather than a coincidental 4.
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) { // stale large value rather than a coincidental 4.
BitVec warm_a = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec warm_b = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {
BitVecPush(&warm_a, (i % 2) == 1); BitVecDeinit(&warm_b);
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
for (int i = 0; i < 4; i++) {
BitVecPush(&bv2, false); WriteFmt("Testing BitVecEditDistance insertion term\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true); WriteFmt("Testing BitVecJaccardSimilarity rejects bad second operand\n");
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bad = {0}; WriteFmt("Testing BitVecCorrelation with bv1 shorter than bv2 (no OOB)\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCorrelation with bv2 shorter than bv1 (no OOB)\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEntropy on an unbalanced (3 ones, 1 zero) vector\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecBestAlignment all-mismatch best offset == 3\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCosineSimilarity of identical vectors == 1.0\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEntropy of a 3:1 distribution\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; static bool test_entropy_unbalanced_value_m13(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec bv = BitVecInit(base); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1011");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1011");
push_bits(&bv2, "11"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "11");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "11");
push_bits(&bv2, "000"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1010");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "1010");
push_bits(&bv2, "10"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");
push_bits(&bv2, "11"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&bv1, "0011");
push_bits(&bv2, "11");- In
Io.Read.c:344:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;- In
Io.Read.c:839:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;- In
Io.Read.c:909:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;- In
Io.Read.c:961:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;- In
Io.Read.c:1480:
static bool test_m32_zstralloc_zero_maxlen_reads_full(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmn"; // 50 chars, no spaces/backslashes
- In
Io.Read.c:1504:
static bool test_m32_zstralloc_null_fmt_reads_full(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmn"; // 50 chars
- In
Io.Read.c:2043:
static bool test_read_escape_budget_anchor(void) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
Zstr p = "\\n\\n#rest";
StrReadFmt(p, "{}#", out);- In
Io.Read.c:2082:
static bool test_read_long_string_no_cap(void) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
// Quoted string of 50 chars: max_read_len (= rem_in) must allow the full
// read; the `max_read_len = rem_in` survivor would cap it at 42.
WriteFmt("Testing basic BitVec pattern functions\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindPattern function\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindLastPattern function\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindAllPattern function\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; bool test_bitvec_find_all_pattern_vec(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecFindAllPattern Vec form\n"); WriteFmt("Testing BitVec pattern edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVec pattern stress tests\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecStartsWith basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecStartsWith edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEndsWith basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecEndsWith edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFindPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecContainsAt basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecContainsAt edge cases\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecCountPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRFindPattern basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReplace basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReplaceAll basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecMatches basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecFuzzyMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRegexMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecPrefixMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
bool result = true; BitVec *p2 = VecPtrAt(&patterns, 2);
*p0 = BitVecInit(ALLOCATOR_OF(&alloc));
*p1 = BitVecInit(ALLOCATOR_OF(&alloc));
*p2 = BitVecInit(ALLOCATOR_OF(&alloc));
*p0 = BitVecInit(ALLOCATOR_OF(&alloc));
*p1 = BitVecInit(ALLOCATOR_OF(&alloc));
*p2 = BitVecInit(ALLOCATOR_OF(&alloc)); *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
*p1 = BitVecInit(ALLOCATOR_OF(&alloc));
*p2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Pattern 0: 111 (should not match)
WriteFmt("Testing BitVecSuffixMatch basic functionality\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
bool result = true; BitVec *p2 = VecPtrAt(&patterns, 2);
*p0 = BitVecInit(ALLOCATOR_OF(&alloc));
*p1 = BitVecInit(ALLOCATOR_OF(&alloc));
*p2 = BitVecInit(ALLOCATOR_OF(&alloc));
*p0 = BitVecInit(ALLOCATOR_OF(&alloc));
*p1 = BitVecInit(ALLOCATOR_OF(&alloc));
*p2 = BitVecInit(ALLOCATOR_OF(&alloc)); *p0 = BitVecInit(ALLOCATOR_OF(&alloc));
*p1 = BitVecInit(ALLOCATOR_OF(&alloc));
*p2 = BitVecInit(ALLOCATOR_OF(&alloc));
// Pattern 0: 111 (should not match)
bool test_find_last_pattern_exact_length_match(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); bool test_find_all_pattern_vec_exact_length_match(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
push_bits(&suffix, "101"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
push_bits(&pattern, "101"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "101");
push_bits(&pattern, "101"); WriteFmt("Testing BitVecRFindPattern window-condition (ge_to_lt)\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRFindPattern window-condition (add_to_sub)\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRFindPattern window-value (add_to_sub)\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRFindPattern loop-seed (add_to_sub)\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecRFindPattern loop-guard (gt_to_ge)\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReplaceAll found-flag init\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReplaceAll forward-scan direction\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; static bool test_replace_all_absent_no_change(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_replace_all_inserts_new_bits(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_matches_mismatch_returns_false(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_fuzzy_equal_length_match(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_fuzzy_match_position(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_fuzzy_no_match_completes_loop(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); WriteFmt("Testing bitvec_regex_match_str returns false on non-match\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true;- In
BitVec.Init.c:29:
// Test basic initialization
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Check initial state
- In
BitVec.Init.c:51:
WriteFmt("Testing BitVecDeinit\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data to make sure deinitialization works with allocated memory
- In
BitVec.Init.c:83:
WriteFmt("Testing BitVecReserve\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Reserve space for 50 bits
WriteFmt("Testing BitVecClear\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data
WriteFmt("Testing BitVecResize\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some initial data
// Test multiple initializations
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc)); // Test multiple initializations
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc)); BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec bv3 = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&bv1) == 0) && (BitVecLen(&bv2) == 0) && (BitVecLen(&bv3) == 0); WriteFmt("Testing BitVecReserve edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecReu64 edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; WriteFmt("Testing BitVecClear edge cases\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bool result = true; // Test multiple init/deinit cycles
for (int cycle = 0; cycle < 100; cycle++) {
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
// Add some data
// failure rather than aborting. The Must variant aborts, so use it here
// to validate the deadend abort path.
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecMustReserve(&bv, SIZE_MAX); // failure rather than aborting. The Must variant aborts, so use it here
// to validate the deadend abort path.
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecMustResize(&bv, SIZE_MAX); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInitWithCapacity(64, ALLOCATOR_OF(&alloc));
bool result = (BitVecCapacity(&bv) == 64); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInitWithCapacity(64, ALLOCATOR_OF(&alloc));
bool result = (BitVecByteSize(&bv) == 8);- In
Io.Leak.c:53:
bool test_leak_sci_nonzero_digits_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
// Float backed by a SEPARATE heap so only the formatter scratch shows
- In
Io.Leak.c:58:
// up in dbg's live count.
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("12345.67", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Io.Leak.c:81:
bool test_leak_sci_zero_digits_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
HeapAllocator fa = HeapAllocatorInit();- In
Io.Leak.c:84:
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("0.0", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Io.Leak.c:107:
bool test_leak_decimal_withdot_canonical_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
HeapAllocator fa = HeapAllocatorInit();- In
Io.Leak.c:110:
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("3.14159", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Io.Leak.c:134:
bool test_leak_decimal_nodot_canonical_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
HeapAllocator fa = HeapAllocatorInit();- In
Io.Leak.c:137:
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("42", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Io.Leak.c:170:
bool test_leak_read_int_prior_value_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
// Seed the destination with a heap-backed Int (multi-limb) so the old
- In
Io.Leak.c:197:
bool test_leak_read_float_prior_value_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
// Seed with a heap-backed Float (wide significand) so the old significand
- In
Io.Leak.c:226:
bool test_leak_write_zstr_hex_per_byte_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
Zstr s = "AB"; // multi-byte Zstr -> hex loop runs per byte
- In
Io.Leak.c:250:
bool test_leak_write_i64_temp_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Allocator *adbg = ALLOCATOR_OF(&dbg);
i32 v = -123456;- In
Io.Leak.c:274:
#define LEAK_WRITE_PRELUDE() \
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG); \
Allocator *adbg = ALLOCATOR_OF(&dbg); \
Str out = StrInit(adbg); \
bool ok = true- In
Io.Leak.c:298:
bool test_leak_write_str_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Str s = StrInit(ALLOCATOR_OF(&va));
StrAppendFmt(&s, "payload");
LEAK_WRITE_PRELUDE();- In
Io.Leak.c:312:
bool test_leak_write_int_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Int v = IntFromStr("123456789012345678901234567890", ALLOCATOR_OF(&va));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);- In
Io.Leak.c:325:
bool test_leak_write_float_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Float v = FloatFromStr("2.718281828", ALLOCATOR_OF(&va));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);- In
Io.Leak.c:338:
bool test_leak_write_bitvec_freed(void) {
HeapAllocator va = HeapAllocatorInit();
BitVec v = BitVecInit(ALLOCATOR_OF(&va));
BitVecResize(&v, 12);
LEAK_WRITE_PRELUDE();- In
Io.Leak.c:359:
bool test_leak_write_str_hex_per_byte_freed(void) {
HeapAllocator sa = HeapAllocatorInit();
Str s = StrInit(ALLOCATOR_OF(&sa));
for (int i = 0; i < 8; ++i)
StrPushBackR(&s, (char)0xAB);- In
Io.Leak.c:363:
StrPushBackR(&s, (char)0xAB);
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str out = StrInit(ALLOCATOR_OF(&dbg));
bool ok = StrAppendFmt(&out, "{x}", s) && (StrLen(&out) > 0);
StrDeinit(&out);- In
Io.Leak.c:383:
bool test_leak_write_float_default_freed(void) {
HeapAllocator fa = HeapAllocatorInit();
Float f = FloatFromStr("12345678901234567890123456789012345678901234567890.5", ALLOCATOR_OF(&fa));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", f) && (StrLen(&out) > 0);- In
Io.Leak.c:405:
static bool leak_quoted_unterminated(Zstr input, Zstr fmt) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = input;
StrReadFmt(p, fmt, s); // reader frees s on the unterminated/error branch
- In
Io.Leak.c:432:
bool test_leak_read_unquoted_bad_escape_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = "aaaaaaaaaaaaaaaaaaaaaaaa\\q"; // 24 'a' + invalid \q
StrReadFmt(p, "{}", s);- In
Io.Leak.c:444:
static bool leak_bitvec_overflow(Zstr input) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
BitVec bv = BitVecInit(ALLOCATOR_OF(&dbg));
Zstr p = input;
StrReadFmt(p, "{}", bv);- In
Io.Leak.c:465:
bool test_leak_read_float_exp_overflow_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float fv = FloatInit(ALLOCATOR_OF(&dbg));
Zstr p = "1e99999999999999999999999999999999999999999999999999";
StrReadFmt(p, "{}", fv);
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
ArgParse p = ArgParseInit("prog", "an about line", adbg);- In
Dwarf.Mut.c:215:
bool test_dwm_file_off_init_zero_when_file_oob(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.Mut.c:256:
bool test_dwm_dir_off_init_zero_when_dir_zero(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// One-off header: file "only.c" with dir index 0 (no directory).
- In
Dwarf.Mut.c:335:
bool test_dwm_advance_pc_saturates_on_overflow(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.Mut.c:364:
bool test_dwm_fixed_advance_pc_saturates_on_overflow(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.Mut.c:396:
bool test_dwm_const_add_pc_saturates_on_overflow(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.Mut.c:426:
bool test_dwm_special_opcode_saturates_on_overflow(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.Mut.c:457:
bool test_dwm_trailing_short_bytes_fail_build(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.Mut.c:511:
bool test_dwm_build_failure_frees_lines(void) {
DebugAllocator dbg = leak_alloc();
Allocator *base = ALLOCATOR_OF(&dbg);
// Use a program that emits at least one row (so out->entries holds heap
- In
Dwarf.Mut.c:544:
bool test_dwm_collect_failure_frees_cu_strings(void) {
DebugAllocator dbg = leak_alloc();
Allocator *base = ALLOCATOR_OF(&dbg);
u8 dl[256];- In
File.Mut.c:68:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
// Seed a temp path that exists on disk (so the open succeeds).
- In
MachO.c:227:
// MachoDeinit on success.
static bool open_blob(Macho *out, const u8 *bytes, u32 len, DefaultAllocator *alloc) {
return MachoOpenFromMemoryCopy(out, bytes, len, ALLOCATOR_OF(alloc));
}- In
MachO.c:347:
bool test_macho_parses_synthetic_blob(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_macho_blob();- In
MachO.c:376:
bool test_macho_resolves_address(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_macho_blob();- In
MachO.c:405:
bool test_macho_rejects_fat_binary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 fat[64];- In
MachO.c:424:
bool test_macho_find_section(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_macho_blob();- In
MachO.c:450:
DefaultAllocator alloc = DefaultAllocatorInit();
Macho m;
bool opened = MachoOpenFromMemoryCopy(&m, bytes, len, ALLOCATOR_OF(&alloc));
if (opened)
MachoDeinit(&m);- In
MachO.c:523:
bool test_macho_resolve_bounded_by_next(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
build_two_symbol_blob();- In
MachO.c:574:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Macho m;- In
MachO.c:608:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Macho m;- In
MachO.c:1120:
bool test_mh2_header_min_exact_size(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[HDR_SIZE];- In
MachO.c:1142:
bool test_mh2_segment_min_no_sections(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[HDR_SIZE + SEG64_HDR];- In
MachO.c:1179:
bool test_mh2_segment_name_full16(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[HDR_SIZE + SEG64_HDR];- In
MachO.c:1210:
bool test_mh2_two_sections_count(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[HDR_SIZE + SEG64_HDR + 2 * SECT64_SIZE];- In
MachO.c:1233:
bool test_mh2_section_names_full16(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[HDR_SIZE + SEG64_HDR + SECT64_SIZE];- In
MachO.c:1272:
bool test_mh2_loadcmds_tight_fit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Header + one LC_SEGMENT_64 (72, nsects 0). Buffer length is
- In
MachO.c:1308:
bool test_mh2_minimal_cmdsize8(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 buf[HDR_SIZE + 8];- In
MachO.c:1336:
bool test_mh2_resolve_picks_max_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// First-iterated symbol has the larger value.
- In
MachO.c:1369:
bool test_mh2_resolve_equal_values_keeps_later(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u64 values[2] = {0x100000010ull, 0x100000010ull}; // equal values
- In
MachO.c:1403:
bool test_mh2_open_valid_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// Mint a unique temp path, then write a minimal valid Mach-O to it.
- In
MachO.c:1446:
bool test_mh2_open_invalid_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
Str path;- In
MachO.c:1487:
bool test_mh2_fail_path_frees_buffer(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
// Header advertises sizeofcmds = 16 but the single command claims a
- In
Elf.c:257:
Elf elf;
bool opened = ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc));
if (!opened) {
DefaultAllocatorDeinit(&alloc);- In
Elf.c:280:
Elf elf;
if (!ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:303:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
if (!ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:317:
Elf elf;
if (!ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:350:
Elf elf;
bool ok = ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc));
if (!ok) {
DefaultAllocatorDeinit(&alloc);- In
Elf.c:394:
Elf elf;
bool ok = ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc));
if (ok) {
ok = VecLen(&elf.segments) == 2;- In
Elf.c:420:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:456:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:472:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, bytes, len, ALLOCATOR_OF(&alloc));
if (opened)
ElfDeinit(&elf);- In
Elf.c:711:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, dbg_blob, sizeof(dbg_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:747:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:773:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:795:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:861:
Elf elf;
bool ok = ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc));
if (ok) {
// Names resolved through the in-range shstrtab.
- In
Elf.c:885:
Elf elf;
bool ok = ElfOpenFromMemoryCopy(&elf, bad, sizeof(bad), ALLOCATOR_OF(&alloc));
if (ok) {
// Empty shstrtab => every section name decodes to "".
- In
Elf.c:909:
Elf elf;
bool ok = ElfOpenFromMemoryCopy(&elf, bad, sizeof(bad), ALLOCATOR_OF(&alloc));
if (ok) {
ok = VecLen(&elf.sections) == N_SECTIONS;- In
Elf.c:988:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1048:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1107:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1127:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1155:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1182:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
if (!ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1209:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1267:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, b, sizeof(b), ALLOCATOR_OF(&alloc));
bool ok = opened && elf.header.shnum == 1 && VecLen(&elf.sections) == 1;
if (opened)- In
Elf.c:1287:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, elf_blob, sizeof(elf_blob), ALLOCATOR_OF(&alloc));
if (opened)
ElfDeinit(&elf);- In
Elf.c:1416:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, bad, sizeof(bad), ALLOCATOR_OF(&alloc));
if (opened) {
// Should not happen on real code; clean up and fail the test.
- In
Elf.c:1438:
DefaultAllocator alloc = DefaultAllocatorInit();
Elf elf;
bool opened = ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc));
bool ok = opened && elf.header.machine == ELF_MACHINE_HOST && VecLen(&elf.sections) > 0;
if (opened)- In
Elf.c:1676:
static bool open_sym(Elf *elf, DefaultAllocator *alloc) {
build_sym_blob();
return ElfOpenFromMemoryCopy(elf, sym_blob, sizeof(sym_blob), ALLOCATOR_OF(alloc));
}- In
Elf.c:1762:
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, sym_blob, sizeof(sym_blob), ALLOCATOR_OF(&alloc));
if (opened)
ElfDeinit(&elf);- In
Elf.c:1920:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, bid_blob, sizeof(bid_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1941:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, bid_blob, sizeof(bid_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1963:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, bid_blob, sizeof(bid_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:1984:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, bid_blob, sizeof(bid_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2006:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, bid_blob, sizeof(bid_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2072:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, dl_blob, sizeof(dl_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2100:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, dl_blob, sizeof(dl_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2120:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, dl_blob, sizeof(dl_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2143:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, dl_blob, sizeof(dl_blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2213:
Elf elf;
bool opened = ElfOpenFromMemoryCopy(&elf, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (opened)
ElfDeinit(&elf);- In
Elf.c:2281:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2315:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Elf.c:2344:
Elf elf;
if (!ElfOpenFromMemoryCopy(&elf, blob, sizeof(blob), ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false; WriteFmt("Testing BitVecRunLengths with NULL runs array\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
bool values[5]; WriteFmt("Testing BitVecRunLengths with NULL values array\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
u64 runs[5]; WriteFmt("Testing BitVecRunLengths with zero max_runs\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv, true);
u64 runs[5]; // no public setter exists -- the whole point of this test is to plant
// length>0 with data==NULL so ValidateBitVec aborts in the foreach prologue.
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc));
bv.length = 5;
bv.capacity = 10; bool test_run_lengths_vec_null_bv_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecRunLengths (vec) with NULL bitvector\n"); DefaultAllocator alloc = DefaultAllocatorInit();
typedef List(int) LI;
LI li = ListInit(ALLOCATOR_OF(&alloc));
ListForeach(&li, i) {
(void)i; WriteFmt("Testing BitVecFindPattern(NULL, pattern) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); WriteFmt("Testing BitVecFindPattern(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPush(&source, false); WriteFmt("Testing BitVecFindLastPattern(NULL, pattern) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); WriteFmt("Testing BitVecFindLastPattern(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPush(&source, false); WriteFmt("Testing BitVecFindAllPattern(source, NULL, results, 10) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
size results[10];
BitVecPush(&source, true); WriteFmt("Testing BitVecFindAllPattern(source, pattern, NULL, 10) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPush(&source, false); WriteFmt("Testing BitVecFindAllPattern(source, pattern, results, 0) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
size results[10];
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
size results[10];
BitVecPush(&source, true);
WriteFmt("Testing BitVecStartsWith(NULL, prefix) - should fatal\n");
BitVec prefix = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&prefix, true);
BitVecStartsWith(NULL, &prefix);
WriteFmt("Testing BitVecStartsWith(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecStartsWith(&source, NULL);
WriteFmt("Testing BitVecEndsWith(NULL, suffix) - should fatal\n");
BitVec suffix = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&suffix, true);
BitVecEndsWith(NULL, &suffix);
WriteFmt("Testing BitVecEndsWith(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecEndsWith(&source, NULL);
WriteFmt("Testing BitVecContainsAt(NULL, pattern, 0) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true);
BitVecContainsAt(NULL, &pattern, 0);
WriteFmt("Testing BitVecContainsAt(source, NULL, 0) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecContainsAt(&source, NULL, 0);
WriteFmt("Testing BitVecMatches(NULL, pattern, wildcard) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); WriteFmt("Testing BitVecMatches(NULL, pattern, wildcard) - should fatal\n");
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec wildcard = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true);
BitVecPush(&wildcard, false);
WriteFmt("Testing BitVecRegexMatch(source, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecRegexMatch(&source, (Zstr)NULL); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecPrefixMatch(NULL, patterns, 1) - should fatal\n");
BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
BitVecPush(VecPtrAt(&vp, 0), true);
BitVecPrefixMatch(NULL, &vp);
WriteFmt("Testing BitVecPrefixMatch(source, NULL, 1) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecPrefixMatch(&source, NULL); DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecSuffixMatch(NULL, patterns, 1) - should fatal\n");
BitVecs vp = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
BitVecPush(VecPtrAt(&vp, 0), true);
BitVecSuffixMatch(NULL, &vp);
WriteFmt("Testing BitVecSuffixMatch(source, NULL, 1) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecSuffixMatch(&source, NULL); bool test_find_all_pattern_vec_null_bv_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecFindAllPattern (vec) with NULL bitvector\n"); bool test_find_all_pattern_vec_null_pattern_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
WriteFmt("Testing BitVecFindAllPattern (vec) with NULL pattern\n"); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&pattern, true); DefaultAllocator alloc = DefaultAllocatorInit();
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true); WriteFmt("Testing BitVecReplace(src, old, NULL) with old absent - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "0000");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&source, "0000");
push_bits(&old_pattern, "111"); // not present in source
BitVec bad = {0}; // magic mismatch -> ValidateBitVec aborts
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1"); BitVec bad = {0}; // magic mismatch -> ValidateBitVec aborts
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1");
push_bits(&new_pattern, "0"); WriteFmt("Testing BitVecReplaceAll(empty, NULL, new) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&new_pattern, "0");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec new_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&new_pattern, "0"); WriteFmt("Testing BitVecReplaceAll(empty, old, NULL) - should fatal\n");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1");
BitVec source = BitVecInit(ALLOCATOR_OF(&alloc)); // empty
BitVec old_pattern = BitVecInit(ALLOCATOR_OF(&alloc));
push_bits(&old_pattern, "1"); static bool test_matches_null_pattern_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_matches_null_wildcard_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); static bool test_fuzzy_null_source_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec pattern = BitVecInit(base); static bool test_fuzzy_null_pattern_aborts(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
BitVec source = BitVecInit(base); WriteFmt("Testing BitVecPrefixMatch(NULL, empty) - should fatal\n");
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
// Empty patterns: with validation present this aborts on the NULL bv;
WriteFmt("Testing BitVecSuffixMatch(NULL, empty) - should fatal\n");
BitVecs patterns = VecInitWithDeepCopy(NULL, BitVecDeinit, ALLOCATOR_OF(&alloc));
// Empty patterns: with validation present this aborts on the NULL bv;
- In
Dwarf.c:23:
Elf elf;
if (!ElfOpen(&elf, "/proc/self/exe", ALLOCATOR_OF(&alloc))) {
DefaultAllocatorDeinit(&alloc);
return false;- In
Dwarf.c:29:
DwarfLines lines;
bool built = DwarfLinesBuildFromElf(&lines, &elf, ALLOCATOR_OF(&alloc));
bool ok = built && VecLen(&lines.entries) > 0;- In
Dwarf.c:45:
bool test_dwarf_resolves_helper_to_source_file(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SymbolResolver res;- In
Dwarf.c:91:
bool test_dwarf_cfi_finds_fde_for_self(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SymbolResolver res;- In
Dwarf.c:163:
bool test_dwarf_functions_resolves_helper_to_name(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
SymbolResolver res;- In
Dwarf.c:287:
bool test_dwarf_info_resolves_known_function(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 info[128];- In
Dwarf.c:317:
bool test_dwarf_info_rejects_64bit_length_form(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 info[16];- In
Dwarf.c:338:
bool test_dwarf_info_rejects_missing_abbrev(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 info[128];- In
Dwarf.c:357:
bool test_dwarf_info_rejects_abbrev_offset_oob(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 info[128];- In
Dwarf.c:379:
bool test_dwarf_info_rejects_unit_length_overrun(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 info[128];- In
Dwarf.c:398:
bool test_dwarf_info_empty_is_success(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
DwarfFunctions fns;- In
Dwarf.c:575:
bool test_dwarf_lines_resolves_known_program(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[256];- In
Dwarf.c:628:
bool test_dwarf_lines_rejects_unit_length_overrun(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[256];- In
Dwarf.c:752:
static bool lines_fixture_open(LinesFixture *fx, const u8 *prog, u64 prog_len) {
fx->alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&fx->alloc);
static u8 dl[1024];
u64 dl_len = build_debug_line_prog(dl, prog, prog_len);- In
Dwarf.c:1517:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
static u8 dl[1024];
u64 dl_len = build_debug_line_prog(dl, prog, prog_len);- In
Dwarf.c:1614:
bool test_dw2_fixed_advance_pc(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[64];- In
Dwarf.c:1654:
bool test_dw2_fixed_advance_pc_exact_operand(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[64];- In
Dwarf.c:1701:
bool test_dw2_special_opcode_addr_and_line(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[64];- In
Dwarf.c:1737:
bool test_dw2_special_opcode_div_rem_split(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[64];- In
Dwarf.c:1771:
bool test_dw2_special_opcode_emits_row(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[64];- In
Dwarf.c:1820:
bool test_dw2_set_isa_consumes_operand(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[64];- In
Dwarf.c:1956:
bool test_dw2_unknown_opcode_skips_operands(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// opcode_base = 20 -> std_opcode_lengths has 19 entries (opcodes 1..19).
- In
Dwarf.c:2009:
bool test_dw2_unknown_opcode_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
// opcode_base = 15 -> 14 std_opcode_lengths entries (opcodes 1..14).
- In
Dwarf.c:2049:
bool test_dw2_two_sequences_resolve(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 prog[96];- In
Dwarf.c:2101:
bool test_dw3_standard_program_resolves_file_dir_line(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2185:
bool test_dw3_dir_zero_offset_yields_null_dir(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2240:
bool test_dw3_special_opcode_uses_line_base_range(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2292:
bool test_dw3_reset_between_sequences(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2370:
bool test_dw3_unit_length_overrun_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2412:
bool test_dw3_default_is_stmt_false_propagates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2466:
bool test_dw4_lines_build_and_resolve(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[256];- In
Dwarf.c:2509:
bool test_dw4_lines_rejects_64bit_length(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[256];- In
Dwarf.c:2545:
bool test_dw4_lines_rejects_unit_length_overrun(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[256];- In
Dwarf.c:2581:
bool test_dw4_resolve_boundaries(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[256];- In
Dwarf.c:2635:
bool test_dw4_build_frees_cu_strings(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
u8 dl[256];- In
Dwarf.c:2681:
bool test_dw4_deinit_releases_string_pool(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *base = ALLOCATOR_OF(&dbg);
u8 dl[256];- In
Dwarf.c:2739:
bool test_dx_std_opcode_count_keeps_file_table_in_sync(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2796:
bool test_dx_skip_tables_runs_over_nonempty_tables(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2851:
bool test_dx_skip_tables_scans_nul_terminator(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2912:
bool test_dx_extended_length_overrun_is_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512];- In
Dwarf.c:2960:
bool test_dx_extended_length_in_bounds_builds(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);
u8 dl[512]; static bool test_al_reset_stats_preserves_outstanding(void) {
HeapAllocator heap = HeapAllocatorInit();
Allocator *alloc = ALLOCATOR_OF(&heap);
void *p = AllocatorAlloc(alloc, 64, false);- In
Blind.c:24:
static bool kv_parse_is_leak_free(Zstr src) {
DebugAllocator dbg = kv_lean_debug_allocator();
Allocator *base = ALLOCATOR_OF(&dbg);
bool ok = true;- In
Leak.c:33:
bool test_kv_leak_value_strip_frees_old_buffer(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
KvConfig cfg = KvConfigInit(adbg);- In
Leak.c:69:
bool test_kv_leak_parse_frees_local_key(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
KvConfig cfg = KvConfigInit(adbg);- In
Leak.c:101:
bool test_kv_leak_parse_frees_local_value(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
KvConfig cfg = KvConfigInit(adbg);- In
Leak.c:135:
bool test_kv_leak_get_ptr_zstr_frees_lookup(void) {
DebugAllocator dbg = DebugAllocatorInit();
Allocator *adbg = ALLOCATOR_OF(&dbg);
KvConfig cfg = KvConfigInit(adbg);