Skip to content

Commit d58412b

Browse files
steveklabnikalexcrichton
authored andcommitted
Add more description to c_str::unwrap().
It's unclear what you are supposed to do with this memory. Let's make that more clear.
1 parent 9e3d0b0 commit d58412b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustrt/c_str.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ impl CString {
123123
}
124124

125125
/// Unwraps the wrapped `*libc::c_char` from the `CString` wrapper.
126-
/// Any ownership of the buffer by the `CString` wrapper is forgotten.
126+
///
127+
/// The original object is destructed after this method is called, and if
128+
/// the underlying pointer was previously allocated, care must be taken to
129+
/// ensure that it is deallocated properly.
127130
pub unsafe fn unwrap(self) -> *libc::c_char {
128131
let mut c_str = self;
129132
c_str.owns_buffer_ = false;

0 commit comments

Comments
 (0)