* Update ffi_util.rs

* Update rocksdb.rs
master
hh9527 8 years ago committed by GitHub
parent 7f2188c39d
commit 2bace2ca0d
  1. 3
      src/ffi_util.rs
  2. 7
      src/rocksdb.rs

@ -15,11 +15,10 @@
use libc::{self, c_char, c_void}; use libc::{self, c_char, c_void};
use std::ffi::CStr; use std::ffi::CStr;
use std::str;
pub fn error_message(ptr: *const c_char) -> String { pub fn error_message(ptr: *const c_char) -> String {
let cstr = unsafe { CStr::from_ptr(ptr as *const _) }; let cstr = unsafe { CStr::from_ptr(ptr as *const _) };
let s = str::from_utf8(cstr.to_bytes()).unwrap().to_owned(); let s = String::from_utf8_lossy(cstr.to_bytes()).into();
unsafe { unsafe {
libc::free(ptr as *mut c_void); libc::free(ptr as *mut c_void);
} }

@ -911,10 +911,9 @@ fn errors_do_stuff() {
// The DB will still be open when we try to destroy it and the lock should fail. // The DB will still be open when we try to destroy it and the lock should fail.
match DB::destroy(&opts, path) { match DB::destroy(&opts, path) {
Err(s) => { Err(s) => {
assert!(s == let message = s.to_string();
Error::new("IO error: lock _rust_rocksdb_error/LOCK: No \ assert!(message.find("IO error:").is_some());
locks available" assert!(message.find("_rust_rocksdb_error/LOCK:").is_some());
.to_owned()))
} }
Ok(_) => panic!("should fail"), Ok(_) => panic!("should fail"),
} }

Loading…
Cancel
Save