提交 3b818ede 编写于 作者: E Erick Tryzelaar

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`
上级 cf753308
......@@ -76,7 +76,7 @@ unsafe fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
match try_take_task_borrow_list() {
None => { // not recording borrows
let msg = "borrowed";
do msg.as_buf |msg_p, _| {
do msg.as_c_str |msg_p| {
sys::begin_unwind_(msg_p as *c_char, file, line);
}
}
......@@ -92,7 +92,7 @@ unsafe fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
sep = " and at ";
}
}
do msg.as_buf |msg_p, _| {
do msg.as_c_str |msg_p| {
sys::begin_unwind_(msg_p as *c_char, file, line)
}
}
......@@ -231,7 +231,7 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
let br = borrow_list.pop();
if br.box != a || br.file != file || br.line != line {
let err = fmt!("wrong borrow found, br=%?", br);
do err.as_buf |msg_p, _| {
do err.as_c_str |msg_p| {
sys::begin_unwind_(msg_p as *c_char, file, line)
}
}
......
......@@ -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 @@ fn fail_with(cause: ~str, file: &'static str, line: uint) -> ! {
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)
}
}
}
......
......@@ -56,8 +56,8 @@ pub fn fail_bounds_check(file: *c_char, line: size_t,
index: size_t, len: size_t) {
let msg = fmt!("index out of bounds: the len is %d but the index is %d",
len as int, index as int);
do msg.as_buf |p, _len| {
fail_(p as *c_char, file, line);
do msg.as_c_str |buf| {
fail_(buf, file, line);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册