@@ -36,10 +36,10 @@ not tied to the lifetime of the original string/data buffer). If C strings are
36
36
heavily used in applications, then caching may be advisable to prevent
37
37
unnecessary amounts of allocations.
38
38
39
- Be carefull to remember that the memory is managed by libc's malloc and not
40
- by jemalloc which is the 'normal' rust memory allocator.
41
- That means that the CString pointers should only be freed with
42
- alloc::libc_heap::malloc_raw if you intend to do that on your own.
39
+ Be carefull to remember that the memory is managed by C allocator API and not
40
+ by Rust allocator API .
41
+ That means that the CString pointers should only be freed with C allocator API
42
+ if you intend to do that on your own.
43
43
44
44
An example of creating and using a C string would be:
45
45
@@ -97,7 +97,7 @@ pub struct CString {
97
97
impl Clone for CString {
98
98
/// Clone this CString into a new, uniquely owned CString. For safety
99
99
/// reasons, this is always a deep clone with the memory allocated
100
- /// with libc 's malloc , rather than the usual shallow clone.
100
+ /// with C 's allocator API , rather than the usual shallow clone.
101
101
fn clone ( & self ) -> CString {
102
102
let len = self . len ( ) + 1 ;
103
103
let buf = unsafe { malloc_raw ( len) } as * mut libc:: c_char ;
@@ -136,8 +136,9 @@ impl<S: hash::Writer> hash::Hash<S> for CString {
136
136
}
137
137
138
138
impl CString {
139
- /// Create a C String from a pointer, with memory managed by libc's malloc,
140
- /// so do not call it with a pointer allocated by jemalloc.
139
+ /// Create a C String from a pointer, with memory managed by C's allocator
140
+ /// API, so do not call it with a pointer to memory managed by Rust's
141
+ /// allocator API.
141
142
///
142
143
///# Failure
143
144
///
0 commit comments