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

@ -111,10 +111,11 @@ static int dtrak_prepare_data(int model, device_data_t &dev_data)
while (model != g_models[i].model_num && g_models[i].model_num != 0xEE)
i++;
dev_data.model = copy_string(g_models[i].name);
dev_data.vendor = (const char *)malloc(strlen(g_models[i].name) + 1);
sscanf(g_models[i].name, "%[A-Za-z] ", (char *)dev_data.vendor);
dev_data.product = copy_string(strchr(g_models[i].name, ' ') + 1);
dev_data.model = g_models[i].name;
dev_data.vendor.clear();
for (const char *s = g_models[i].name; isalpha(*s); ++s)
dev_data.vendor += *s;
dev_data.product = strchr(g_models[i].name, ' ') + 1;
d = get_descriptor(g_models[i].type, g_models[i].libdc_num);
if (d)
@ -520,7 +521,7 @@ static char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct
libdc_model = dtrak_prepare_data(tmp_1byte, devdata);
if (!libdc_model)
report_error(translate("gettextFromC", "[Warning] Manual dive # %d\n"), dt_dive->number);
dt_dive->dc.model = copy_string(devdata.model);
dt_dive->dc.model = copy_string(devdata.model.c_str());
/*
* Air usage, unknown use. Probably allows or deny manually entering gas