mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
dc_location.rs: rewrite is_marker in safe Rust
This commit is contained in:
committed by
holger krekel
parent
648d3d78aa
commit
a5553f98af
@@ -214,11 +214,8 @@ pub fn dc_get_locations(
|
|||||||
|
|
||||||
if 0 != (*loc).msg_id {
|
if 0 != (*loc).msg_id {
|
||||||
let txt: String = row.get(9)?;
|
let txt: String = row.get(9)?;
|
||||||
let txt_c = to_cstring(txt);
|
if is_marker(&txt) {
|
||||||
if 0 != is_marker(txt_c) {
|
(*loc).marker = to_cstring(txt);
|
||||||
(*loc).marker = txt_c;
|
|
||||||
} else {
|
|
||||||
free(txt_c as *mut _);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(loc)
|
Ok(loc)
|
||||||
@@ -235,16 +232,8 @@ pub fn dc_get_locations(
|
|||||||
.unwrap_or_else(|_| std::ptr::null_mut())
|
.unwrap_or_else(|_| std::ptr::null_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should be bool /rtn
|
fn is_marker(txt: &str) -> bool {
|
||||||
unsafe fn is_marker(txt: *const libc::c_char) -> libc::c_int {
|
txt.len() == 1 && txt.chars().next().unwrap() != ' '
|
||||||
if !txt.is_null() {
|
|
||||||
let len: libc::c_int = dc_utf8_strlen(txt) as libc::c_int;
|
|
||||||
if len == 1 && *txt.offset(0isize) as libc::c_int != ' ' as i32 {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_delete_all_locations(context: &Context) -> bool {
|
pub fn dc_delete_all_locations(context: &Context) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user