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

@ -56,7 +56,7 @@ extern void free_dc_contents(struct divecomputer *dc);
extern int get_depth_at_time(const struct divecomputer *dc, unsigned int time);
extern void free_dive_dcs(struct divecomputer *dc);
extern struct sample *prepare_sample(struct divecomputer *dc);
extern struct sample *add_sample(const struct sample *sample, int time, struct divecomputer *dc);
extern void append_sample(const struct sample &sample, struct divecomputer *dc);
extern void fixup_dc_duration(struct divecomputer *dc);
extern unsigned int dc_airtemp(const struct divecomputer *dc);
extern unsigned int dc_watertemp(const struct divecomputer *dc);