Make dc_array_new and dc_array_new_typed safe

Just like Box::into_raw, these functions are safe,
even though the caller is responsible for the allocated structure.
This commit is contained in:
Alexander Krotov
2019-07-22 14:00:00 +03:00
parent 1dfad65afd
commit 05aca2c529
5 changed files with 9 additions and 9 deletions

View File

@@ -521,7 +521,7 @@ pub fn dc_get_fresh_msgs(context: &Context) -> *mut dc_array_t {
&[10, 9, if 0 != show_deaddrop { 2 } else { 0 }],
|row| row.get(0),
|rows| {
let ret = unsafe { dc_array_new(128 as size_t) };
let ret = dc_array_new(128 as size_t);
for row in rows {
let id = row?;
@@ -560,7 +560,7 @@ pub fn dc_search_msgs(
AND ct.blocked=0 AND (m.txt LIKE ? OR ct.name LIKE ?) ORDER BY m.timestamp DESC,m.id DESC;"
};
let ret = unsafe { dc_array_new(100 as size_t) };
let ret = dc_array_new(100 as size_t);
let success = context
.sql