core: add make_manually_added_dc() function

For reasons of symmetry (there is a is_manually_added_dc()
function), create a make_manually_added_dc() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-10-21 18:12:11 +02:00 committed by Dirk Hohndel
parent f687e51d4b
commit 261f07dfa4
5 changed files with 12 additions and 4 deletions

View file

@ -549,8 +549,15 @@ void free_dc(struct divecomputer *dc)
free(dc);
}
static const char *manual_dc_name = "manually added dive";
bool is_manually_added_dc(const struct divecomputer *dc)
{
return dc && dc->samples <= 50 &&
same_string(dc->model, "manually added dive");
same_string(dc->model, manual_dc_name);
}
void make_manually_added_dc(struct divecomputer *dc)
{
free((void *)dc->model);
dc->model = strdup(manual_dc_name);
}