mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 14:26:30 +03:00
Remove to_cstring() naming convention ambiguity
Add a trait for str.strdup() to replace to_cstring() which avoid the signature ambiguity with .to_string(). Also instruduce CString::yolo() as a shortcut to CString::new().unwrap() and use it whenever the variable does can be deallocated by going out of scope. This is less error prone. Use some Path.to_c_string() functions where possible.
This commit is contained in:
committed by
Floris Bruynooghe
parent
e7428887d0
commit
b6b0849bce
@@ -256,7 +256,7 @@ impl<'a> Chatlist<'a> {
|
||||
|
||||
let mut ret = dc_lot_new();
|
||||
if index >= self.ids.len() {
|
||||
(*ret).text2 = to_cstring("ErrBadChatlistIndex");
|
||||
(*ret).text2 = "ErrBadChatlistIndex".strdup();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ impl<'a> Chatlist<'a> {
|
||||
chat = dc_chat_new(self.context);
|
||||
let chat_to_delete = chat;
|
||||
if !dc_chat_load_from_db(chat, self.ids[index].0) {
|
||||
(*ret).text2 = to_cstring("ErrCannotReadChat");
|
||||
(*ret).text2 = "ErrCannotReadChat".strdup();
|
||||
dc_chat_unref(chat_to_delete);
|
||||
|
||||
return ret;
|
||||
@@ -293,7 +293,7 @@ impl<'a> Chatlist<'a> {
|
||||
if (*chat).id == DC_CHAT_ID_ARCHIVED_LINK as u32 {
|
||||
(*ret).text2 = dc_strdup(0 as *const libc::c_char)
|
||||
} else if lastmsg.is_null() || (*lastmsg).from_id == DC_CONTACT_ID_SELF as u32 {
|
||||
(*ret).text2 = to_cstring(self.context.stock_str(StockMessage::NoMessages));
|
||||
(*ret).text2 = self.context.stock_str(StockMessage::NoMessages).strdup();
|
||||
} else {
|
||||
dc_lot_fill(ret, lastmsg, chat, lastcontact, self.context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user