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:
Floris Bruynooghe
2019-08-01 00:08:23 +02:00
committed by Floris Bruynooghe
parent e7428887d0
commit b6b0849bce
31 changed files with 395 additions and 381 deletions

View File

@@ -1312,9 +1312,8 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
}
if !filename_parts.is_empty() {
free(desired_filename as *mut libc::c_void);
let parts_c = to_cstring(filename_parts);
desired_filename = dc_decode_ext_header(parts_c);
free(parts_c as *mut _);
let parts_c = CString::yolo(filename_parts);
desired_filename = dc_decode_ext_header(parts_c.as_ptr());
}
if desired_filename.is_null() {
let param = mailmime_find_ct_parameter(