Free err strings correctly

master
David Greenberg 9 years ago
parent 8796fd89ff
commit 3c25739170
  1. 7
      src/rocksdb.rs

@ -163,8 +163,11 @@ pub trait Writable {
fn error_message(ptr: *const i8) -> String {
let c_str = unsafe { CStr::from_ptr(ptr) };
//TODO I think we're leaking the c string here; should be a call to free once realloced into rust String
from_utf8(c_str.to_bytes()).unwrap().to_owned()
let s = from_utf8(c_str.to_bytes()).unwrap().to_owned();
unsafe{
libc::free(ptr as *mut libc::c_void);
}
s
}
impl RocksDB {

Loading…
Cancel
Save