Skip to content

Commit 50d179d

Browse files
committed
Doc says to avoid mixing allocator instead of forbiding it
1 parent 6a37692 commit 50d179d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/librustrt/c_str.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ unnecessary amounts of allocations.
3838
3939
Be carefull to remember that the memory is managed by C allocator API and not
4040
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.
41+
That means that the CString pointers should be freed with C allocator API
42+
if you intend to do that on your own, as the behaviour if you free them with
43+
Rust's allocator API is not well defined
4344
4445
An example of creating and using a C string would be:
4546
@@ -137,8 +138,8 @@ impl<S: hash::Writer> hash::Hash<S> for CString {
137138

138139
impl CString {
139140
/// 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+
/// API, so avoid calling it with a pointer to memory managed by Rust's
142+
/// allocator API, as the behaviour would not be well defined.
142143
///
143144
///# Failure
144145
///
@@ -272,7 +273,7 @@ impl CString {
272273
/// forgotten, meaning that the backing allocation of this
273274
/// `CString` is not automatically freed if it owns the
274275
/// allocation. In this case, a user of `.unwrap()` should ensure
275-
/// the allocation is freed, to avoid leaking memory. You have to
276+
/// the allocation is freed, to avoid leaking memory. You should
276277
/// use libc's memory allocator in this case.
277278
///
278279
/// Prefer `.as_ptr()` when just retrieving a pointer to the

0 commit comments

Comments
 (0)