summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-19 11:41:09 -0500
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-19 15:06:39 -0500
commit77f9bf06fded941aeff049cf5d3c0c3f2785d011 (patch)
tree2aba8de2c7e0af36a37bd3f0938da19e4e5ff733 /planner.c
parent6ed189f32c466f99167ab6657264a45da4b56e8e (diff)
downloadsubsurface-77f9bf06fded941aeff049cf5d3c0c3f2785d011.tar.gz
Planner: correctly free divedatapoints
Simply setting the pointer to NULL leaks memory. And that C++ recursive two function implementation... oh boy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r--planner.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/planner.c b/planner.c
index ea180fb0a..f986af48b 100644
--- a/planner.c
+++ b/planner.c
@@ -348,13 +348,17 @@ gas_error_exit:
return;
}
-void free_dps(struct divedatapoint *dp)
+void free_dps(struct diveplan *diveplan)
{
+ if (!diveplan)
+ return;
+ struct divedatapoint *dp = diveplan->dp;
while (dp) {
struct divedatapoint *ndp = dp->next;
free(dp);
dp = ndp;
}
+ diveplan->dp = NULL;
}
struct divedatapoint *create_dp(int time_incr, int depth, struct gasmix gasmix, int po2)