Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi: const char* parameters have no specified length (null-terminated) #1909

Open
ichordev opened this issue Jan 14, 2025 · 0 comments
Open

Comments

@ichordev
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant