diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-04-19 10:50:23 +0200 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-10-06 10:09:10 +0200 |
| commit | ff66e24475e24eddfa6b86903405f3dbcf6bb456 (patch) | |
| tree | 747c2495e072d8474008ef07bada41a5b4934b63 | |
| parent | f021813ed443b4ef7224d1934881abecf53977a7 (diff) | |
| download | mail-ff66e24475e24eddfa6b86903405f3dbcf6bb456.tar.gz | |
fix ffi for db revision
| -rw-r--r-- | src/database.rs | 10 | ||||
| -rw-r--r-- | src/ffi.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/database.rs b/src/database.rs index f1d743b..3fc2c4e 100644 --- a/src/database.rs +++ b/src/database.rs @@ -2,7 +2,7 @@ use std::ops::Drop; use std::iter::Iterator; use std::ptr; use std::path::Path; -use std::ffi::CString; +use std::ffi::{CStr, CString}; use libc; @@ -126,14 +126,14 @@ impl Database { } pub fn revision(&self) -> Revision { - let uuid_p: *mut libc::c_char = ptr::null_mut(); + let uuid_p: *const libc::c_char = ptr::null(); let revision = unsafe { - ffi::notmuch_database_get_revision(self.0, (&uuid_p) as *const _ as *const *mut libc::c_char) + ffi::notmuch_database_get_revision(self.0, (&uuid_p) as *const _ as *mut *const libc::c_char) }; - let uuid = unsafe { CString::from_raw(uuid_p) }; + let uuid = unsafe { CStr::from_ptr(uuid_p) }; - Revision{revision, uuid: uuid.to_str().unwrap().to_string()} + Revision{revision, uuid: uuid.to_string_lossy().into_owned()} } pub fn needs_upgrade(&self) -> bool { @@ -399,7 +399,7 @@ extern { /// this database. Two revision numbers are only comparable if they /// have the same database UUID. pub fn notmuch_database_get_revision(notmuch: *mut notmuch_database_t, - uuid: *const *mut c_char) + uuid: *mut *const c_char) -> c_ulong; /// Retrieve a directory object from the database for 'path'. |
