Return Option<String> from read_autoconf_file

This commit is contained in:
Alexander Krotov
2019-10-06 02:10:08 +03:00
parent 6fbde21995
commit 1b13107181
3 changed files with 11 additions and 25 deletions

View File

@@ -633,7 +633,7 @@ pub fn dc_stop_ongoing_process(context: &Context) {
};
}
pub fn read_autoconf_file(context: &Context, url: &str) -> *mut libc::c_char {
pub fn read_autoconf_file(context: &Context, url: &str) -> Option<String> {
info!(context, "Testing {} ...", url);
match reqwest::Client::new()
@@ -641,11 +641,11 @@ pub fn read_autoconf_file(context: &Context, url: &str) -> *mut libc::c_char {
.send()
.and_then(|mut res| res.text())
{
Ok(res) => unsafe { res.strdup() },
Ok(res) => Some(res),
Err(_err) => {
info!(context, "Can\'t read file.",);
std::ptr::null_mut()
None
}
}
}