Skip to content

Commit 3493847

Browse files
committed
Remove incorrect documentation.
1 parent 6f08115 commit 3493847

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/librustrt/c_str.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@ strings can validly contain a null-byte in the middle of the string (0 is a
2222
valid Unicode codepoint). This means that not all Rust strings can actually be
2323
translated to C strings.
2424
25-
# Creation of a C string
26-
27-
A C string is managed through the `CString` type defined in this module. It
28-
"owns" the internal buffer of characters and will automatically deallocate the
29-
buffer when the string is dropped. The `ToCStr` trait is implemented for `&str`
30-
and `&[u8]`, but the conversions can fail due to some of the limitations
31-
explained above.
32-
33-
This also means that currently whenever a C string is created, an allocation
34-
must be performed to place the data elsewhere (the lifetime of the C string is
35-
not tied to the lifetime of the original string/data buffer). If C strings are
36-
heavily used in applications, then caching may be advisable to prevent
37-
unnecessary amounts of allocations.
38-
3925
Be carefull to remember that the memory is managed by C allocator API and not
4026
by Rust allocator API.
4127
That means that the CString pointers should be freed with C allocator API
@@ -432,7 +418,7 @@ impl ToCStr for [u8] {
432418
ptr::copy_memory(buf, self.as_ptr(), self_len);
433419
*buf.offset(self_len as int) = 0;
434420

435-
CString::new_owned(buf as *mut i8)
421+
CString::new_owned(buf as *mut libc::c_char)
436422
}
437423

438424
fn with_c_str<T>(&self, f: |*const libc::c_char| -> T) -> T {

0 commit comments

Comments
 (0)