cloudflare / cloudflare/quiche
ffi: `const char*` parameters have no specified length (null-terminated)
- Dominant language
- Rust
- Stars
- 11.8k
- Forks
- 1.1k
- Avg merge
- 21h 9m
- Merged PRs (30d)
- 6
Description
I come from another language with slices, so it's rather vexing that quiche's FFI doesn't expose string parameters as slices (pointer + length), but rather as null-terminated arrays (pointer + memory leak). This means that before sending a string slice to quiche I have to null-terminate it and pass only its pointer to quiche, only for quiche to find the null-terminator and re-slice it anyway. In other words:
> safe bounds-checked slice ⇒ unsafe null-terminated string ⇒ safe bounds-checked slice
I would prefer if there were alternative functions that take a pointer & length so that I don't have to do this dance. Many C libraries (including portions of the C standard library) also expect `const char*`s to be passed alongside a length, so I don't think it's unreasonable to expect it here.
Contributor guide
Assessment
This issue has not been assessed yet.