mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
uemis: replace C-strings by std::string and std::string_view
The string code of uemis-downloader.cpp was broken in more ways than can be listed here. Notably, it brazenly refused to free any memory allocated for the parameters buffer. Using std::string and std::string_view should plug all those memory holes. That made it necessary to do some major refactoring. This was done blind and therefore will break. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
16e19b550b
commit
58b3583b3b
9 changed files with 384 additions and 403 deletions
|
@ -1141,7 +1141,7 @@ static int cancel_cb(void *)
|
|||
return import_thread_cancelled;
|
||||
}
|
||||
|
||||
static const char *do_device_import(device_data_t *data)
|
||||
static std::string do_device_import(device_data_t *data)
|
||||
{
|
||||
dc_status_t rc;
|
||||
dc_device_t *device = data->device;
|
||||
|
@ -1202,7 +1202,7 @@ static const char *do_device_import(device_data_t *data)
|
|||
}
|
||||
|
||||
/* All good */
|
||||
return NULL;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
static dc_timer_t *logfunc_timer = NULL;
|
||||
|
@ -1465,10 +1465,9 @@ static dc_status_t sync_divecomputer_time(dc_device_t *device)
|
|||
return dc_device_timesync(device, &now);
|
||||
}
|
||||
|
||||
const char *do_libdivecomputer_import(device_data_t *data)
|
||||
std::string do_libdivecomputer_import(device_data_t *data)
|
||||
{
|
||||
dc_status_t rc;
|
||||
const char *err;
|
||||
FILE *fp = NULL;
|
||||
|
||||
import_dive_number = 0;
|
||||
|
@ -1495,7 +1494,7 @@ const char *do_libdivecomputer_import(device_data_t *data)
|
|||
fprintf(data->libdc_logfile, "built with libdivecomputer v%s\n", dc_version(NULL));
|
||||
}
|
||||
|
||||
err = translate("gettextFromC", "Unable to open %s %s (%s)");
|
||||
std::string err = translate("gettextFromC", "Unable to open %s %s (%s)");
|
||||
|
||||
rc = divecomputer_device_open(data);
|
||||
|
||||
|
@ -1518,7 +1517,7 @@ const char *do_libdivecomputer_import(device_data_t *data)
|
|||
/* TODO: Show the logfile to the user on error. */
|
||||
dev_info(data, "Import complete");
|
||||
|
||||
if (!err && data->sync_time) {
|
||||
if (err.empty() && data->sync_time) {
|
||||
dev_info(data, "Syncing dive computer time ...");
|
||||
rc = sync_divecomputer_time(data->device);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue