diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-07-22 21:45:33 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-07-23 16:56:22 -0700 |
| commit | 3b818edeba4dbca7c605ca5600f2d1b4b000120b (patch) | |
| tree | debfc8b7cbf00f368b3f4267048c877ad9549f2a /src/libstd/sys.rs | |
| parent | cf75330807ad908a428e9c162a388e367fb07781 (diff) | |
| download | rust-3b818edeba4dbca7c605ca5600f2d1b4b000120b.tar.gz rust-3b818edeba4dbca7c605ca5600f2d1b4b000120b.zip | |
std and extra: use as_c_str instead of as_buf in a couple places
These uses are assuming the strings are null terminated, so it should be using `as_c_str` instead of `as_buf`
Diffstat (limited to 'src/libstd/sys.rs')
| -rw-r--r-- | src/libstd/sys.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs index 0c497ecef27..28cd2345aab 100644 --- a/src/libstd/sys.rs +++ b/src/libstd/sys.rs @@ -123,13 +123,9 @@ pub trait FailWithCause { impl FailWithCause for ~str { fn fail_with(cause: ~str, file: &'static str, line: uint) -> ! { - do cause.as_buf |msg_buf, _msg_len| { - do file.as_buf |file_buf, _file_len| { - unsafe { - let msg_buf = cast::transmute(msg_buf); - let file_buf = cast::transmute(file_buf); - begin_unwind_(msg_buf, file_buf, line as libc::size_t) - } + do cause.as_c_str |msg_buf| { + do file.as_c_str |file_buf| { + begin_unwind_(msg_buf, file_buf, line as libc::size_t) } } } @@ -137,13 +133,9 @@ impl FailWithCause for ~str { impl FailWithCause for &'static str { fn fail_with(cause: &'static str, file: &'static str, line: uint) -> ! { - do cause.as_buf |msg_buf, _msg_len| { - do file.as_buf |file_buf, _file_len| { - unsafe { - let msg_buf = cast::transmute(msg_buf); - let file_buf = cast::transmute(file_buf); - begin_unwind_(msg_buf, file_buf, line as libc::size_t) - } + do cause.as_c_str |msg_buf| { + do file.as_c_str |file_buf| { + begin_unwind_(msg_buf, file_buf, line as libc::size_t) } } } |
