Update docs and fix string allocation

The docs say you should always unref the string and NULL is never
returned.  The implementation should follow that.
This commit is contained in:
Floris Bruynooghe
2023-03-07 15:36:33 +01:00
parent 4b94eadf5e
commit eec5ae96e8
2 changed files with 12 additions and 5 deletions

View File

@@ -2645,12 +2645,17 @@ void dc_str_unref (char* str);
/** /**
* Creates an object for sending a backup to another device. * Creates an object for sending a backup to another device.
* *
* Before calling this function IO must be stopped using dc_accounts_stop_io()
* or dc_stop_io(). IO should only be restarted once
* dc_backup_provider_wait() has returned.
*
* The backup is sent to through a peer-to-peer channel which is bootstrapped * The backup is sent to through a peer-to-peer channel which is bootstrapped
* by a QR-code. The backup contains the entire state of the account * by a QR-code. The backup contains the entire state of the account
* including credentials. This can be used to setup a new device. * including credentials. This can be used to setup a new device.
* *
* Once this function returns, the backup is being offered to remote devices. * This is a blocking call as some preparations are made like e.g. exporting
* To wait until one device received the backup, use * the database. Once this function returns, the backup is being offered to
* remote devices. To wait until one device received the backup, use
* dc_backup_provider_wait(). Alternatively abort the operation using * dc_backup_provider_wait(). Alternatively abort the operation using
* dc_stop_ongoing_process(). * dc_stop_ongoing_process().
* *
@@ -2706,7 +2711,9 @@ char* dc_backup_provider_get_qr_svg (const dc_backup_provider_t* backup_provider
/** /**
* Waits for the sending to finish and frees the backup provider object. * Waits for the sending to finish and frees the backup provider object.
* *
* This should only be called once. * This is a blocking call and should only be called once. Once this function
* returns IO can be started again using dc_accounts_start_io() or
* dc_start_io().
* *
* @memberof dc_backup_provider_t * @memberof dc_backup_provider_t
* @param context The context. * @param context The context.

View File

@@ -4171,7 +4171,7 @@ pub unsafe extern "C" fn dc_backup_provider_get_qr(
) -> *mut libc::c_char { ) -> *mut libc::c_char {
if provider.is_null() { if provider.is_null() {
eprintln!("ignoring careless call to dc_backup_provider_qr"); eprintln!("ignoring careless call to dc_backup_provider_qr");
return ptr::null_mut(); return "".strdup();
} }
let ffi_provider = &*provider; let ffi_provider = &*provider;
deltachat::qr::format_backup(&ffi_provider.provider.qr()) deltachat::qr::format_backup(&ffi_provider.provider.qr())
@@ -4185,7 +4185,7 @@ pub unsafe extern "C" fn dc_backup_provider_get_qr_svg(
) -> *mut libc::c_char { ) -> *mut libc::c_char {
if provider.is_null() { if provider.is_null() {
eprintln!("ignoring careless call to dc_backup_provider_qr_svg()"); eprintln!("ignoring careless call to dc_backup_provider_qr_svg()");
return ptr::null_mut(); return "".strdup();
} }
let ffi_provider = &*provider; let ffi_provider = &*provider;
let ctx = &*ffi_provider.context; let ctx = &*ffi_provider.context;