core: replace add_sample() by append_sample()

add_sample() was used in only one place, and the return value was
always ignored. It took a time parameter, suggesting that a sample
could be added anywhere, but in reality the sample was added at
the end of the list. It used prepare_sample() that copies data
from the previous sample, just to overwrite it with the newly
added sample.

All in all very weird. Simplify the function: just append the
passed in sample and name it accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-25 08:50:20 +02:00 committed by bstoeger
parent af6201f89c
commit c27314d603
3 changed files with 15 additions and 18 deletions

View file

@ -263,15 +263,9 @@ struct sample *prepare_sample(struct divecomputer *dc)
return NULL;
}
struct sample *add_sample(const struct sample *sample, int time, struct divecomputer *dc)
void append_sample(const struct sample &sample, struct divecomputer *dc)
{
struct sample *p = prepare_sample(dc);
if (p) {
*p = *sample;
p->time.seconds = time;
}
return p;
dc->samples.push_back(sample);
}
/*