about summary refs log tree commit diff
path: root/src/libstd/sys.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-09 21:56:17 -0700
committerbors <bors@rust-lang.org>2013-08-09 21:56:17 -0700
commit60f5011005eda4f08f0c36fe56e4df07ae9a903f (patch)
tree4f3636735525b80b6aa3c6fc37b88a5f9057548c /src/libstd/sys.rs
parente81e81f234731a31fad9afdc2045bef3fbdf1109 (diff)
parentee59aacac490edd619db1c4e2fcd848f793bc3b9 (diff)
auto merge of #8296 : erickt/rust/remove-str-trailing-nulls, r=erickt
This PR fixes #7235 and #3371, which removes trailing nulls from `str` types. Instead, it replaces the creation of c strings with a new type, `std::c_str::CString`, which wraps a malloced byte array, and respects:

*  No interior nulls
* Ends with a trailing null
Diffstat (limited to 'src/libstd/sys.rs')
-rw-r--r--src/libstd/sys.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs
index cf34bd3261a..03e6412fcb8 100644
--- a/src/libstd/sys.rs
+++ b/src/libstd/sys.rs
@@ -12,12 +12,12 @@
 
 #[allow(missing_doc)];
 
+use c_str::ToCStr;
 use cast;
 use io;
 use libc;
 use libc::{c_char, size_t};
 use repr;
-use str::StrSlice;
 use str;
 use unstable::intrinsics;
 
@@ -105,8 +105,8 @@ pub trait FailWithCause {
 
 impl FailWithCause for ~str {
     fn fail_with(cause: ~str, file: &'static str, line: uint) -> ! {
-        do cause.as_c_str |msg_buf| {
-            do file.as_c_str |file_buf| {
+        do cause.to_c_str().with_ref |msg_buf| {
+            do file.to_c_str().with_ref |file_buf| {
                 begin_unwind_(msg_buf, file_buf, line as libc::size_t)
             }
         }
@@ -115,8 +115,8 @@ impl FailWithCause for ~str {
 
 impl FailWithCause for &'static str {
     fn fail_with(cause: &'static str, file: &'static str, line: uint) -> ! {
-        do cause.as_c_str |msg_buf| {
-            do file.as_c_str |file_buf| {
+        do cause.to_c_str().with_ref |msg_buf| {
+            do file.to_c_str().with_ref |file_buf| {
                 begin_unwind_(msg_buf, file_buf, line as libc::size_t)
             }
         }