[PATCH] Clear out old events in create_dive_from_plan

Anton Lundin glance at acc.umu.se
Thu Jul 3 23:50:59 PDT 2014


Previous code where accumulating events from each iteration of the
planning. This code clears the old ones before adding new ones.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 planner.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/planner.c b/planner.c
index 026581d..b0da873 100644
--- a/planner.c
+++ b/planner.c
@@ -246,6 +246,7 @@ static void create_dive_from_plan(struct diveplan *diveplan)
 	struct divecomputer *dc;
 	struct sample *sample;
 	struct gasmix oldgasmix;
+	struct event *ev;
 	cylinder_t *cyl;
 	int oldpo2 = 0;
 	int lasttime = 0;
@@ -261,6 +262,11 @@ static void create_dive_from_plan(struct diveplan *diveplan)
 	reset_cylinders(&displayed_dive);
 	dc = &displayed_dive.dc;
 	free(dc->sample);
+	while (ev = dc->events) {
+		dc->events = dc->events->next;
+		printf("freeing ev: %s\n", ev->name);
+		free(ev);
+	}
 	dc->sample = NULL;
 	dc->samples = 0;
 	dc->alloc_samples = 0;
-- 
1.9.1



More information about the subsurface mailing list