From ff66e24475e24eddfa6b86903405f3dbcf6bb456 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Thu, 19 Apr 2018 10:50:23 +0200 Subject: fix ffi for db revision --- src/database.rs | 10 +++++----- src/ffi.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') 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'. -- cgit v1.2.1