Skip to content

Commit

Permalink
Doc says to avoid mixing allocator instead of forbiding it
Browse files Browse the repository at this point in the history
  • Loading branch information
gamazeps committed Sep 18, 2014
1 parent 6a37692 commit 50d179d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librustrt/c_str.rs
Expand Up @@ -38,8 +38,9 @@ unnecessary amounts of allocations.
Be carefull to remember that the memory is managed by C allocator API and not
by Rust allocator API.
That means that the CString pointers should only be freed with C allocator API
if you intend to do that on your own.
That means that the CString pointers should be freed with C allocator API
if you intend to do that on your own, as the behaviour if you free them with
Rust's allocator API is not well defined
An example of creating and using a C string would be:
Expand Down Expand Up @@ -137,8 +138,8 @@ impl<S: hash::Writer> hash::Hash<S> for CString {

impl CString {
/// Create a C String from a pointer, with memory managed by C's allocator
/// API, so do not call it with a pointer to memory managed by Rust's
/// allocator API.
/// API, so avoid calling it with a pointer to memory managed by Rust's
/// allocator API, as the behaviour would not be well defined.
///
///# Failure
///
Expand Down Expand Up @@ -272,7 +273,7 @@ impl CString {
/// forgotten, meaning that the backing allocation of this
/// `CString` is not automatically freed if it owns the
/// allocation. In this case, a user of `.unwrap()` should ensure
/// the allocation is freed, to avoid leaking memory. You have to
/// the allocation is freed, to avoid leaking memory. You should
/// use libc's memory allocator in this case.
///
/// Prefer `.as_ptr()` when just retrieving a pointer to the
Expand Down

4 comments on commit 50d179d

@bors
Copy link
Contributor

@bors bors commented on 50d179d Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at gamazeps@50d179d

@bors
Copy link
Contributor

@bors bors commented on 50d179d Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging gamazeps/rust/issue17210 = 50d179d into auto

@bors
Copy link
Contributor

@bors bors commented on 50d179d Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamazeps/rust/issue17210 = 50d179d merged ok, testing candidate = cc25c4ee

@bors
Copy link
Contributor

@bors bors commented on 50d179d Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.