summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-18 23:33:39 -0500
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-19 22:54:00 -0500
commit46b125782ee0e8af84c929deaa1ed34f53e7bcd0 (patch)
treee9f4eba166841cb50965bb53a851a5bfddba6565 /dive.c
parent5a96389cd3039ac822482232b3102106bbe70a5a (diff)
downloadsubsurface-46b125782ee0e8af84c929deaa1ed34f53e7bcd0.tar.gz
Hook up adding a dive
This gets things mostly right. It creates a dive and uses the planner widget to create samples which are copied into the dive. It fills in some reasonable defaults (DC model, timestamp), but doesn't allow editing the timestamp (or the temperatures and air pressure). On accept the planner gets reset and the dive appears correctly in the dive list. Cancel still needs to be handled. And I bet there are many subtle bugs lurking here and there. But it's a start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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) {