Every string-input API should expose the four effective branches of the
StrCmp shape:
Str * — owned string
Zstr — NUL-terminated const char *
char * — MSVC string-literal synonym for Zstr (kept deliberately; see Zstr.h)
(Zstr, len) — fixed-length view, as a separate OVERLOAD arity → a _cstr worker
Implementation rule for the (Zstr, len) worker
Make a transient copy only if required:
- byte compare / scan callee → thread the bound via
ZstrCompareN (or a
length-bounded loop) with an exact-length guard — no copy.
Str-taking callee → the existing StrInitFromCstr(ptr, len, alloc)
transient-copy idiom (mirror the _zstr sibling) — never a hand-built
Str / __magic internals poke.
- NUL-terminating syscall (
open/mkdir/…) → bounded stack-buffer copy
(file_open_n template).
Private snake_case workers live in each module's Private.h.
Done (PR #44)
File (FileOpen, FileReadAndClose), Elf (ElfOpen), ProcMaps; and Dir,
Dns, KvConfig, MachO, Http, Pe, Pdb, Socket.
Remaining — the sweep this issue tracks
Std/Container/Str/Ops — StrSplit, StrSplitToIters (no length form)
Std/Container/Str/Insert — has _4 counted forms; audit for the full shape
Std/Container/Int/Convert — IntFromStr / IntTryFromStr families
Std/Container/Float/Convert
Std/Container/BitVec/Convert — partial; complete + audit
Std/Io
Std/File — FileWriteAndClose (from_buf / from_str / from_bytes)
Parsers/Elf — ElfFindSection
Audit path (run per module after adding)
Str-taking macro → four effective branches → correct expansion → transient copies only if required. This caught a real prefix false-match bug in
macho_find_section_cstr during the first batch, so audit the untested
_cstr forms line by line.
Every string-input API should expose the four effective branches of the
StrCmpshape:Str *— owned stringZstr— NUL-terminatedconst char *char *— MSVC string-literal synonym forZstr(kept deliberately; seeZstr.h)(Zstr, len)— fixed-length view, as a separateOVERLOADarity → a_cstrworkerImplementation rule for the
(Zstr, len)workerMake a transient copy only if required:
ZstrCompareN(or alength-bounded loop) with an exact-length guard — no copy.
Str-taking callee → the existingStrInitFromCstr(ptr, len, alloc)transient-copy idiom (mirror the
_zstrsibling) — never a hand-builtStr/__magicinternals poke.open/mkdir/…) → bounded stack-buffer copy(
file_open_ntemplate).Private
snake_caseworkers live in each module'sPrivate.h.Done (PR #44)
File(FileOpen, FileReadAndClose),Elf(ElfOpen),ProcMaps; andDir,Dns,KvConfig,MachO,Http,Pe,Pdb,Socket.Remaining — the sweep this issue tracks
Std/Container/Str/Ops—StrSplit,StrSplitToIters(no length form)Std/Container/Str/Insert— has_4counted forms; audit for the full shapeStd/Container/Int/Convert—IntFromStr/IntTryFromStrfamiliesStd/Container/Float/ConvertStd/Container/BitVec/Convert— partial; complete + auditStd/IoStd/File—FileWriteAndClose(from_buf / from_str / from_bytes)Parsers/Elf—ElfFindSectionAudit path (run per module after adding)
Str-taking macro → four effective branches → correct expansion → transient copies only if required. This caught a real prefix false-match bug inmacho_find_section_cstrduring the first batch, so audit the untested_cstrforms line by line.