Skip to content

Commit d6257b3

Browse files
committed
std: remove unnecessary test from c_str.drop and use safer transmute
1 parent e053bff commit d6257b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/c_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl CString {
5757
/// Fails if the CString is null.
5858
pub fn with_mut_ref<T>(&mut self, f: &fn(*mut libc::c_char) -> T) -> T {
5959
if self.buf.is_null() { fail!("CString is null!"); }
60-
f(unsafe { cast::transmute(self.buf) })
60+
f(unsafe { cast::transmute_mut_unsafe(self.buf) })
6161
}
6262

6363
/// Returns true if the CString is a null.
@@ -99,7 +99,7 @@ impl CString {
9999

100100
impl Drop for CString {
101101
fn drop(&self) {
102-
if self.owns_buffer_ && self.buf.is_not_null() {
102+
if self.owns_buffer_ {
103103
unsafe {
104104
libc::free(self.buf as *libc::c_void)
105105
}

0 commit comments

Comments
 (0)