-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add more description to c_str::unwrap(). #15119
Conversation
@@ -124,6 +124,9 @@ impl CString { | |||
|
|||
/// Unwraps the wrapped `*libc::c_char` from the `CString` wrapper. | |||
/// Any ownership of the buffer by the `CString` wrapper is forgotten. | |||
/// | |||
/// The original object is destructed after unwrap() is called on it and | |||
/// the memory must be freed with `libc::free()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be slightly misleading as it may not always be true. The buffer could be borrowed from another source or perhaps be in static memory. Perhaps this could be combined with the above sentence to clarify things a bit? Or just alluding to the face that it must be freed if it was previously allocated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to any particular suggestion. Maybe the second?
"Because it is a C string, it must be freed with libc::free, rather than automatically by Rust."
or something. That sentence is terrible, but maybe something along those lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unwraps the wrapped
*libc::c_char
from theCString
wrapper.The original
CString
object is destructed after this method is called,
and if the underlying pointer was previously allocated care must be taken
to ensure that it is deallocated.
Something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. I'll update this soon.
Updated. |
/// | ||
/// The original object is destructed after this method is called, and if | ||
/// the underlying pointer was previously allocated, care must be taken to | ||
/// ensure that is deallocated properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"that it is"
r=me with a squash |
Typo fixed and sqaushed. |
Oh dear, this seems to have reverted a bunch of updates to submodules |
Oh my. I suck at git. One moment. |
Whew. Bad @steveklabnik! I should remove After some more git-fu, this should be good now. Should. |
It's unclear what you are supposed to do with this memory. Let's make that more clear.
Support more intrinsics in mir interpreter Increases passed tests on self from 49 to 52
It's unclear what you are supposed to do with this memory.
Let's make that more clear.