Commit 47329cae authored by Jay Lee's avatar Jay Lee

use global extern crate

parent 3048f8fd
...@@ -7,3 +7,7 @@ Cargo.lock ...@@ -7,3 +7,7 @@ Cargo.lock
_rust_rocksdb* _rust_rocksdb*
*rlib *rlib
tags tags
.idea/
out/
*.iml
\ No newline at end of file
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
extern crate libc; use libc::{c_char, c_int, c_void, size_t};
use self::libc::{c_char, c_int, c_void, size_t};
use std::ffi::CString; use std::ffi::CString;
use std::mem; use std::mem;
use std::slice; use std::slice;
......
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
extern crate libc; use libc::{self, c_char, c_int, c_void, size_t};
use self::libc::{c_char, c_int, c_void, size_t};
use std::ffi::CStr; use std::ffi::CStr;
use std::str::from_utf8; use std::str::from_utf8;
...@@ -92,7 +91,7 @@ pub fn error_message(ptr: *const i8) -> String { ...@@ -92,7 +91,7 @@ pub fn error_message(ptr: *const i8) -> String {
let c_str = unsafe { CStr::from_ptr(ptr as *const _) }; 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 c_void);
} }
s s
} }
......
...@@ -12,14 +12,17 @@ ...@@ -12,14 +12,17 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
pub use ffi as rocksdb_ffi; extern crate libc;
pub use ffi::{DBCompactionStyle, DBComparator, new_bloom_filter};
pub use rocksdb::{DB, DBIterator, DBVector, Direction, IteratorMode, Writable,
WriteBatch};
pub use rocksdb_options::{BlockBasedOptions, Options, WriteOptions};
pub use merge_operator::MergeOperands;
pub mod rocksdb; pub mod rocksdb;
pub mod ffi; pub mod ffi;
pub mod rocksdb_options; pub mod rocksdb_options;
pub mod merge_operator; pub mod merge_operator;
pub mod comparator; pub mod comparator;
pub use ffi::{DBCompactionStyle, DBComparator, new_bloom_filter,
self as rocksdb_ffi};
pub use rocksdb::{DB, DBIterator, DBVector, Direction, IteratorMode, Writable,
WriteBatch};
pub use rocksdb_options::{BlockBasedOptions, Options, WriteOptions};
pub use merge_operator::MergeOperands;
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
extern crate libc; use libc::{self, c_char, c_int, c_void, size_t};
use self::libc::{c_char, c_int, c_void, size_t};
use std::ffi::CString; use std::ffi::CString;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
......
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
extern crate libc;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::ffi::CString; use std::ffi::CString;
use std::fs; use std::fs;
...@@ -23,7 +20,7 @@ use std::path::Path; ...@@ -23,7 +20,7 @@ use std::path::Path;
use std::slice; use std::slice;
use std::str::from_utf8; use std::str::from_utf8;
use self::libc::{c_void, size_t}; use libc::{self, c_int, c_void, size_t};
use rocksdb_ffi::{self, DBCFHandle, error_message}; use rocksdb_ffi::{self, DBCFHandle, error_message};
use rocksdb_options::{Options, WriteOptions}; use rocksdb_options::{Options, WriteOptions};
...@@ -313,7 +310,7 @@ impl DB { ...@@ -313,7 +310,7 @@ impl DB {
let nfam = cfs_v.len(); let nfam = cfs_v.len();
unsafe { unsafe {
db = rocksdb_ffi::rocksdb_open_column_families(opts.inner, cpath_ptr as *const _, db = rocksdb_ffi::rocksdb_open_column_families(opts.inner, cpath_ptr as *const _,
nfam as libc::c_int, nfam as c_int,
cfnames.as_ptr() as *const _, cfnames.as_ptr() as *const _,
copts, handles, err_ptr); copts, handles, err_ptr);
} }
...@@ -848,7 +845,7 @@ impl Deref for DBVector { ...@@ -848,7 +845,7 @@ impl Deref for DBVector {
impl Drop for DBVector { impl Drop for DBVector {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
libc::free(self.base as *mut libc::c_void); libc::free(self.base as *mut c_void);
} }
} }
} }
......
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
extern crate libc; use libc::{c_int, size_t};
use self::libc::{c_int, size_t};
use std::ffi::CString; use std::ffi::CString;
use std::mem; use std::mem;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment