Closed
Description
This will leak the ptr. Valgrind will complain.
use core::libc::{c_void, malloc, free};
struct SmartPtr(*c_void);
impl Drop for SmartPtr {
fn finalize(&self) {
unsafe {
error!("end ptr: %x", **self as uint);
free(**self);
}
}
}
fn main() {
unsafe {
let junk = malloc(4);
error!("start ptr: %x", junk as uint);
let _junkbox = SmartPtr(junk);
}
}