File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ impl<T : ?Sized> Box<T> {
124124 #[ unstable( feature = "box_raw" ,
125125 reason = "may be renamed or moved out of Box scope" ) ]
126126 #[ inline]
127+ // NB: may want to be called from_ptr, see comments on CStr::from_ptr
127128 pub unsafe fn from_raw ( raw : * mut T ) -> Self {
128129 mem:: transmute ( raw)
129130 }
@@ -147,6 +148,7 @@ impl<T : ?Sized> Box<T> {
147148 /// ```
148149 #[ unstable( feature = "box_raw" , reason = "may be renamed" ) ]
149150 #[ inline]
151+ // NB: may want to be called into_ptr, see comments on CStr::from_ptr
150152 pub fn into_raw ( b : Box < T > ) -> * mut T {
151153 unsafe { mem:: transmute ( b) }
152154 }
Original file line number Diff line number Diff line change @@ -206,6 +206,9 @@ impl CString {
206206 /// `into_ptr`. The length of the string will be recalculated
207207 /// using the pointer.
208208 #[ unstable( feature = "cstr_memory" , reason = "recently added" ) ]
209+ // NB: may want to be called from_raw, needs to consider CStr::from_ptr,
210+ // Box::from_raw (or whatever it's currently called), and
211+ // slice::from_raw_parts
209212 pub unsafe fn from_ptr ( ptr : * const libc:: c_char ) -> CString {
210213 let len = libc:: strlen ( ptr) + 1 ; // Including the NUL byte
211214 let slice = slice:: from_raw_parts ( ptr, len as usize ) ;
@@ -221,6 +224,7 @@ impl CString {
221224 ///
222225 /// Failure to call `from_ptr` will lead to a memory leak.
223226 #[ unstable( feature = "cstr_memory" , reason = "recently added" ) ]
227+ // NB: may want to be called into_raw, see comments on from_ptr
224228 pub fn into_ptr ( self ) -> * const libc:: c_char {
225229 // It is important that the bytes be sized to fit - we need
226230 // the capacity to be determinable from the string length, and
You can’t perform that action at this time.
0 commit comments