aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Van Haerenborgh <vhdirk@gmail.com>2018-04-19 10:50:23 +0200
committerDirk Van Haerenborgh <vhdirk@gmail.com>2018-10-06 10:09:10 +0200
commitff66e24475e24eddfa6b86903405f3dbcf6bb456 (patch)
tree747c2495e072d8474008ef07bada41a5b4934b63
parentf021813ed443b4ef7224d1934881abecf53977a7 (diff)
downloadmail-ff66e24475e24eddfa6b86903405f3dbcf6bb456.tar.gz
fix ffi for db revision
-rw-r--r--src/database.rs10
-rw-r--r--src/ffi.rs2
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 {
diff --git a/src/ffi.rs b/src/ffi.rs
index 5091b43..3c281fa 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -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'.