aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/dive.c10
-rw-r--r--core/dive.h1
-rw-r--r--core/planner.c5
3 files changed, 12 insertions, 4 deletions
diff --git a/core/dive.c b/core/dive.c
index bbfc5322d..3b3ad762d 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -754,6 +754,16 @@ void alloc_samples(struct divecomputer *dc, int num)
}
}
+void free_samples(struct divecomputer *dc)
+{
+ if (dc) {
+ free(dc->sample);
+ dc->sample = 0;
+ dc->samples = 0;
+ dc->alloc_samples = 0;
+ }
+}
+
struct sample *prepare_sample(struct divecomputer *dc)
{
if (dc) {
diff --git a/core/dive.h b/core/dive.h
index 5c7b74395..326dfe54b 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -747,6 +747,7 @@ extern struct dive *clone_dive(struct dive *s);
extern void clear_table(struct dive_table *table);
extern void alloc_samples(struct divecomputer *dc, int num);
+extern void free_samples(struct divecomputer *dc);
extern struct sample *prepare_sample(struct divecomputer *dc);
extern void finish_sample(struct divecomputer *dc);
extern void add_sample_pressure(struct sample *sample, int sensor, int mbar);
diff --git a/core/planner.c b/core/planner.c
index 2b58a2440..cb013799d 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -284,10 +284,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, struct dive *dive,
dc->when = dive->when = diveplan->when;
dc->surface_pressure.mbar = diveplan->surface_pressure;
dc->salinity = diveplan->salinity;
- free(dc->sample);
- dc->sample = NULL;
- dc->samples = 0;
- dc->alloc_samples = 0;
+ free_samples(dc);
while ((ev = dc->events)) {
dc->events = dc->events->next;
free(ev);