e03a6281d6bec681149bfcbbf3085c884acbc3a4
ref/hare/strings/dup.ha:26-35. Returns ([]str | nomem); duplicates every str in the input slice via the now-graduated alloc-slice builtin (#45 unblocked `let s: []str = alloc([], n)?`). Loop body uses appendstr because `[]str` element is 16B and the bare `append` builtin truncates (#11) — pre-allocated cap=s.len means rt_ensure's grow branch never fires. Defer-rollback omitted: with `dup()` still unchecked (graduation tracked by #46), the only nomem source is the initial slice alloc, so there is no partial state to roll back. Will revisit when #46 lands. Empty-input early-return short-circuits via {nil,0,0} because rt_alloc(0) is an mmap of 0 bytes which the kernel rejects with -EINVAL — Hare hands back a sentinel. Localized at the call site pending #47. Tests assert independent allocations at every index of multi-element inputs, including a multibyte row.
Description
No description provided
Languages
C
89.4%
Python
7.2%
Makefile
2.3%
Shell
0.8%
Assembly
0.3%