mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Clear out old events in create_dive_from_plan
Previous code where accumulating events from each iteration of the planning. This code clears the old ones before adding new ones. Fixes #595 [Dirk Hohndel: removed printf, updated comment, slightly moved the code, added parenthesis to silence warning] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5f76185d37
commit
9c6513b11d
1 changed files with 7 additions and 1 deletions
|
@ -246,6 +246,7 @@ static void create_dive_from_plan(struct diveplan *diveplan)
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
struct sample *sample;
|
struct sample *sample;
|
||||||
struct gasmix oldgasmix;
|
struct gasmix oldgasmix;
|
||||||
|
struct event *ev;
|
||||||
cylinder_t *cyl;
|
cylinder_t *cyl;
|
||||||
int oldpo2 = 0;
|
int oldpo2 = 0;
|
||||||
int lasttime = 0;
|
int lasttime = 0;
|
||||||
|
@ -257,13 +258,18 @@ static void create_dive_from_plan(struct diveplan *diveplan)
|
||||||
printf("in create_dive_from_plan\n");
|
printf("in create_dive_from_plan\n");
|
||||||
dump_plan(diveplan);
|
dump_plan(diveplan);
|
||||||
#endif
|
#endif
|
||||||
// reset the cylinders and clear out the samples of the displayed dive so we can restart
|
// reset the cylinders and clear out the samples and events of the
|
||||||
|
// displayed dive so we can restart
|
||||||
reset_cylinders(&displayed_dive);
|
reset_cylinders(&displayed_dive);
|
||||||
dc = &displayed_dive.dc;
|
dc = &displayed_dive.dc;
|
||||||
free(dc->sample);
|
free(dc->sample);
|
||||||
dc->sample = NULL;
|
dc->sample = NULL;
|
||||||
dc->samples = 0;
|
dc->samples = 0;
|
||||||
dc->alloc_samples = 0;
|
dc->alloc_samples = 0;
|
||||||
|
while ((ev = dc->events)) {
|
||||||
|
dc->events = dc->events->next;
|
||||||
|
free(ev);
|
||||||
|
}
|
||||||
dp = diveplan->dp;
|
dp = diveplan->dp;
|
||||||
cyl = &displayed_dive.cylinder[0];
|
cyl = &displayed_dive.cylinder[0];
|
||||||
oldgasmix = cyl->gasmix;
|
oldgasmix = cyl->gasmix;
|
||||||
|
|
Loading…
Add table
Reference in a new issue