Commit 69f1ec6
str + vec: Insert/Push family + stack-init scopes (no allocator)
Stack-init scopes (StrInitStack, VecInitStack) drop their allocator
argument -- NULL allocator is the runtime signal for "non-growable".
validate_vec / vec_aligned_size / VecAlignedOffsetAt tolerate it;
reserve_vec / deinit_vec / reduce_space_vec abort with the dedicated
"vector not growable, no allocator assigned, probably stack inited"
message. VecInitStack takes the element type as its first arg so the
macro mints `name` itself (matches StrInitStack). _Alignas(T) on the
backing struct field guarantees slot alignment for typed Vecs.
IterInitFromVec* fall back to alignment 1 on NULL allocator so a
StrIter over a stack-init Str works. No deep-copy variant: deep-copy
callbacks need an allocator, so heap-backed Vec is the answer.
Str Insert family settles on the unified L/R + *Many shape:
StrInsert/L/R single-char, StrInsertMany(Zstr) and (Zstr, len) carry
the range companion; PushBack and PushFront follow the same shape;
StrMerge defaults to L per the unsuffixed-default-is-L convention.
Migrations: Sys/Proc.c::sys_proc_read_internal now stages reads in a
stack Str + StrMergeR (the old char tmpbuf[1024] + StrPushBackMany
smell). Sys/Dns.c parsers rewritten to StrIter, matching the
Parsers/JSON.c / Parsers/KvConfig.c precedent. dns_resolve_5_zstr /
dns_resolve_4_vec_zstr go StrInitStack end-to-end. Sys/Dir.c and
Log.h::LOG_SYS_* converted to the new scope shape.
Bug fixes: Io.c::write_char_internal was producing `\x\HH` instead of
`\xHH` -- a stray backslash from `cs[3] = {'\\', c1, c2}` after `\\x`
was already emitted. Now matches the sibling pattern in the byte-loop
above. DnsResolverDeinit tolerates a zero-init or partially-failed-init
struct (validate_vec would abort on the zero-magic vec otherwise).
Conventions: CODING-CONVENTIONS.md grows a dedicated "Stack-init APIs"
section. VecCopyInit / VecCopyDeinit accessors added so tests do not
reach into Vec internals.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent ee7850d commit 69f1ec6
54 files changed
Lines changed: 1715 additions & 1221 deletions
File tree
- Bin
- Fuzz/Harness
- Include/Misra
- Parsers
- Std
- Container
- Str
- Vec
- Utility/Iter
- Sys
- Source/Misra
- Parsers
- Std
- Container
- Sys
- Tests
- Json
- KvConfig
- Std
- Util
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
83 | 105 | | |
84 | 106 | | |
85 | 107 | | |
| |||
166 | 188 | | |
167 | 189 | | |
168 | 190 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
172 | 241 | | |
173 | 242 | | |
174 | 243 | | |
| |||
229 | 298 | | |
230 | 299 | | |
231 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
232 | 315 | | |
233 | 316 | | |
234 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
0 commit comments