@@ -22,20 +22,6 @@ strings can validly contain a null-byte in the middle of the string (0 is a
2222valid Unicode codepoint). This means that not all Rust strings can actually be
2323translated 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-
3925Be carefull to remember that the memory is managed by C allocator API and not
4026by Rust allocator API.
4127That 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