summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index f9f78d6bb..66d282d10 100644
--- a/dive.c
+++ b/dive.c
@@ -161,6 +161,19 @@ struct dive *alloc_dive(void)
return dive;
}
+void copy_samples(struct dive* s, struct dive* d)
+{
+ /* instead of carefully copying them one by one and calling add_sample
+ * over and over again, let's just copy the whole blob */
+ if (!s || !d)
+ return;
+ int nr = s->dc.samples;
+ d->dc.samples = nr;
+ d->dc.sample = malloc(nr * sizeof(struct sample));
+ if (d->dc.sample)
+ memcpy(d->dc.sample, s->dc.sample, nr * sizeof(struct sample));
+}
+
struct sample *prepare_sample(struct divecomputer *dc)
{
if (dc) {