-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New c_str/ffi makes error buffer operations harder than necessary #20928
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
Comments
Related to #20475? |
I think it's close. The same function could probably satisfy both issues.
|
It sounds like you don't necessarily want to return a let mut name = [0 as u8; 17];
let res = prctl(PrctlOption::PR_GET_NAME as c_int, name.as_mut_ptr() as c_ulong, 0, 0, 0);
(res, ffi::c_str_to_bytes(name.as_ptr()).to_vec()) |
I think it's better for the interface if I return a cstring, since that's
|
To rust, however, C strings are just binary data. The |
Looking back at this, I'm going to close this as a dupe of #20475 as a |
After the c_str/ffi interface changed in #20444 operations which return strings into preallocated buffer are harder to handle.
Specifically calls like
prctl
can take formprctl(int, char[16])
. This could be handled by:But the name is likely to contain zeros and there's no simple "construct CString until the first zero" function. This shouldn't be a big issue in case of a simple CString type, but since this one is meant specifically for FFI, I think such constructor should be supported.
(rustc 1.0.0-nightly (44a287e 2015-01-08 17:03:40 -0800))
The text was updated successfully, but these errors were encountered: