Commit 224af46
fix(dialog): replace strlen walk in gossamer_dialog_free_path with std.c.free
The previous implementation walked bytes looking for the null terminator to
reconstruct the allocation size, then passed that to Allocator.free. This
was O(n), fragile (paths with embedded nulls would give wrong length), and
technically incorrect — Zig's Allocator.free contract requires the same
slice returned by alloc, which we cannot reconstruct accurately from a raw
u64 pointer.
Since c_allocator wraps libc malloc/free and free() needs no size, call
std.c.free() directly. Add an explicit coupling comment warning maintainers
that this function must stay paired with c_allocator. Add two unit tests:
null-pointer no-op and round-trip allocate/free without crash.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 2025cb7 commit 224af46
1 file changed
Lines changed: 30 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
365 | 375 | | |
366 | 376 | | |
367 | 377 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
374 | 398 | | |
0 commit comments