master
petevine 9 years ago
parent 0f3a6891fa
commit 83c055d43b
  1. 2
      src/ffi.rs
  2. 14
      src/rocksdb.rs

@ -90,7 +90,7 @@ pub enum DBUniversalCompactionStyle {
} }
pub fn error_message(ptr: *const i8) -> String { pub fn error_message(ptr: *const i8) -> String {
let c_str = unsafe { CStr::from_ptr(ptr) }; let c_str = unsafe { CStr::from_ptr(ptr as *const _) };
let s = from_utf8(c_str.to_bytes()).unwrap().to_owned(); let s = from_utf8(c_str.to_bytes()).unwrap().to_owned();
unsafe { unsafe {
libc::free(ptr as *mut libc::c_void); libc::free(ptr as *mut libc::c_void);

@ -264,7 +264,7 @@ impl DB {
if cfs.len() == 0 { if cfs.len() == 0 {
unsafe { unsafe {
db = rocksdb_ffi::rocksdb_open(opts.inner, cpath_ptr, err_ptr); db = rocksdb_ffi::rocksdb_open(opts.inner, cpath_ptr as *const _, err_ptr);
} }
} else { } else {
let mut cfs_v = cfs.to_vec(); let mut cfs_v = cfs.to_vec();
@ -282,7 +282,7 @@ impl DB {
}) })
.collect(); .collect();
let cfnames: Vec<*const i8> = c_cfs.iter() let cfnames: Vec<*const _> = c_cfs.iter()
.map(|cf| cf.as_ptr()) .map(|cf| cf.as_ptr())
.collect(); .collect();
@ -303,9 +303,9 @@ impl DB {
let handles: *const rocksdb_ffi::DBCFHandle = cfhandles.as_ptr(); let handles: *const rocksdb_ffi::DBCFHandle = cfhandles.as_ptr();
let nfam = cfs_v.len(); let nfam = cfs_v.len();
unsafe { unsafe {
db = rocksdb_ffi::rocksdb_open_column_families(opts.inner, cpath_ptr, db = rocksdb_ffi::rocksdb_open_column_families(opts.inner, cpath_ptr as *const _,
nfam as libc::c_int, nfam as libc::c_int,
cfnames.as_ptr(), cfnames.as_ptr() as *const _,
copts, handles, err_ptr); copts, handles, err_ptr);
} }
@ -342,7 +342,7 @@ impl DB {
let mut err: *const i8 = 0 as *const i8; let mut err: *const i8 = 0 as *const i8;
let err_ptr: *mut *const i8 = &mut err; let err_ptr: *mut *const i8 = &mut err;
unsafe { unsafe {
rocksdb_ffi::rocksdb_destroy_db(opts.inner, cpath_ptr, err_ptr); rocksdb_ffi::rocksdb_destroy_db(opts.inner, cpath_ptr as *const _, err_ptr);
} }
if !err.is_null() { if !err.is_null() {
return Err(error_message(err)); return Err(error_message(err));
@ -358,7 +358,7 @@ impl DB {
let mut err: *const i8 = 0 as *const i8; let mut err: *const i8 = 0 as *const i8;
let err_ptr: *mut *const i8 = &mut err; let err_ptr: *mut *const i8 = &mut err;
unsafe { unsafe {
rocksdb_ffi::rocksdb_repair_db(opts.inner, cpath_ptr, err_ptr); rocksdb_ffi::rocksdb_repair_db(opts.inner, cpath_ptr as *const _, err_ptr);
} }
if !err.is_null() { if !err.is_null() {
return Err(error_message(err)); return Err(error_message(err));
@ -474,7 +474,7 @@ impl DB {
let cf_handler = let cf_handler =
rocksdb_ffi::rocksdb_create_column_family(self.inner, rocksdb_ffi::rocksdb_create_column_family(self.inner,
opts.inner, opts.inner,
cname_ptr, cname_ptr as *const _,
err_ptr); err_ptr);
self.cfs.insert(name.to_string(), cf_handler); self.cfs.insert(name.to_string(), cf_handler);
cf_handler cf_handler

Loading…
Cancel
Save