import: turn C-string in device_data_t into std::strings

It was never clear what was a pointer to a static string from
libdivecomputer and what was allocated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-02 21:26:22 +02:00 committed by bstoeger
parent 0915c1ce43
commit 01306224ff
15 changed files with 120 additions and 129 deletions

View file

@ -824,7 +824,7 @@ static dc_status_t prepare_data(int data_model, const char *serial, dc_family_t
dev_data.device = NULL;
dev_data.context = NULL;
if (!data_model) {
dev_data.model = copy_string(manual_dc_name);
dev_data.model = manual_dc_name;
dev_data.descriptor = NULL;
return DC_STATUS_NODEVICE;
}
@ -832,11 +832,11 @@ static dc_status_t prepare_data(int data_model, const char *serial, dc_family_t
if (dev_data.descriptor) {
dev_data.vendor = dc_descriptor_get_vendor(dev_data.descriptor);
dev_data.product = dc_descriptor_get_product(dev_data.descriptor);
concat(&dev_data.model, "", format_string_std("%s %s", dev_data.vendor, dev_data.product));
dev_data.model += dev_data.vendor + " " + dev_data.product;
dev_data.devinfo.serial = (uint32_t) lrint(strtod(serial, NULL));
return DC_STATUS_SUCCESS;
} else {
dev_data.model = copy_string("unsupported dive computer");
dev_data.model = "unsupported dive computer";
dev_data.devinfo.serial = (uint32_t) lrint(strtod(serial, NULL));
return DC_STATUS_UNSUPPORTED;
}
@ -844,7 +844,6 @@ static dc_status_t prepare_data(int data_model, const char *serial, dc_family_t
static void device_data_free(device_data_t &dev_data)
{
free((void *) dev_data.model);
dc_descriptor_free(dev_data.descriptor);
}
@ -952,7 +951,7 @@ extern "C" void smartrak_import(const char *file, struct divelog *log)
dc_fam = DC_FAMILY_UWATEC_ALADIN;
}
rc = prepare_data(dc_model, (char *)col[coln(DCNUMBER)]->bind_ptr, dc_fam, devdata);
smtkdive->dc.model = copy_string(devdata.model);
smtkdive->dc.model = copy_string(devdata.model.c_str());
if (rc == DC_STATUS_SUCCESS && mdb_table.get_len(coln(PROFILE))) {
prf_buffer = static_cast<unsigned char *>(mdb_ole_read_full(mdb, col[coln(PROFILE)], &prf_length));
if (prf_length > 0) {