diff options
| -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'. |
