Merge pull request #3 from AndreyG/master

compilation fixes for upstream rustc
master
Tyler Neely 10 years ago
commit 44efc60b4b
  1. 9
      src/ffi.rs
  2. 19
      src/rocksdb.rs

@ -33,6 +33,15 @@ pub struct RocksDBCache(pub *const c_void);
#[repr(C)] #[repr(C)]
pub struct RocksDBFilterPolicy(pub *const c_void); pub struct RocksDBFilterPolicy(pub *const c_void);
impl Copy for RocksDBOptions {}
impl Copy for RocksDBInstance {}
impl Copy for RocksDBWriteOptions {}
impl Copy for RocksDBReadOptions {}
impl Copy for RocksDBMergeOperator {}
impl Copy for RocksDBBlockBasedTableOptions {}
impl Copy for RocksDBCache {}
impl Copy for RocksDBFilterPolicy {}
pub fn new_bloom_filter(bits: c_int) -> RocksDBFilterPolicy { pub fn new_bloom_filter(bits: c_int) -> RocksDBFilterPolicy {
unsafe { unsafe {
rocksdb_filterpolicy_create_bloom(bits) rocksdb_filterpolicy_create_bloom(bits)

@ -22,7 +22,7 @@ use std::str::from_utf8;
use std::string::raw::from_buf_len; use std::string::raw::from_buf_len;
use std::ptr; use std::ptr;
use std::mem; use std::mem;
use std::slice; use std::ptr::Unique;
use rocksdb_ffi; use rocksdb_ffi;
@ -31,6 +31,8 @@ pub struct RocksDBOptions {
block_options: rocksdb_ffi::RocksDBBlockBasedTableOptions, block_options: rocksdb_ffi::RocksDBBlockBasedTableOptions,
} }
impl Copy for RocksDBOptions {}
impl RocksDBOptions { impl RocksDBOptions {
pub fn new() -> RocksDBOptions { pub fn new() -> RocksDBOptions {
unsafe { unsafe {
@ -463,10 +465,11 @@ pub struct RocksDBVector {
impl RocksDBVector { impl RocksDBVector {
pub fn from_c(val: *mut u8, val_len: size_t) -> RocksDBVector { pub fn from_c(val: *mut u8, val_len: size_t) -> RocksDBVector {
unsafe { unsafe {
let val = Unique(val);
RocksDBVector { RocksDBVector {
inner: inner:
CVec::new_with_dtor(val, val_len as uint, CVec::new_with_dtor(val.0, val_len as uint,
proc(){ libc::free(val as *mut c_void); }) move |:| libc::free(val.0 as *mut libc::c_void))
} }
} }
} }
@ -475,8 +478,8 @@ impl RocksDBVector {
self.inner.as_slice() self.inner.as_slice()
} }
pub fn to_utf8<'a>(&'a self) -> Option<&'a str> { pub fn to_utf8(&self) -> Option<&str> {
from_utf8(self.inner.as_slice()) from_utf8(self.inner.as_slice()).ok()
} }
} }
@ -577,9 +580,9 @@ pub struct MergeOperands<'a> {
} }
impl <'a> MergeOperands<'a> { impl <'a> MergeOperands<'a> {
fn new<'a>(operands_list: *const *const c_char, fn new(operands_list: *const *const c_char,
operands_list_len: *const size_t, operands_list_len: *const size_t,
num_operands: c_int) -> MergeOperands<'a> { num_operands: c_int) -> MergeOperands<'a> {
assert!(num_operands >= 0); assert!(num_operands >= 0);
MergeOperands { MergeOperands {
operands_list: operands_list, operands_list: operands_list,

Loading…
Cancel
Save