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

Make str::as_buf less error prone. #3371

Closed
brson opened this issue Sep 4, 2012 · 2 comments
Closed

Make str::as_buf less error prone. #3371

brson opened this issue Sep 4, 2012 · 2 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@brson
Copy link
Contributor

brson commented Sep 4, 2012

as_buf passes to the callback the length of the string + 1 for the null character. Now that it as_buf also accepts slices this results in some very confusing behavior (#3365).

I suggest we remove the len parameter completely. Users that care about the length should capture it and not assume anything about null termination (as_c_str is for null termination).

@graydon
Copy link
Contributor

graydon commented Jun 20, 2013

See also #7235 , I expect we'll be overhauling all of this.

bors added a commit that referenced this issue Aug 10, 2013
This PR fixes #7235 and #3371, which removes trailing nulls from `str` types. Instead, it replaces the creation of c strings with a new type, `std::c_str::CString`, which wraps a malloced byte array, and respects:

*  No interior nulls
* Ends with a trailing null
@huonw
Copy link
Member

huonw commented Aug 10, 2013

Fixed by #8296.

@huonw huonw closed this as completed Aug 10, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants