summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-19 06:53:28 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-19 20:12:59 +0900
commitb36c8f07c7019fac1bc72d3b44a4486ea6d3458d (patch)
tree3b1fda77933fbde4391885b65e21ded0a7b0bee4 /dive.c
parentcae51ff0aa29d0e8ae312069a7473ff7cc901602 (diff)
downloadsubsurface-b36c8f07c7019fac1bc72d3b44a4486ea6d3458d.tar.gz
Assign the uniq dive ID the moment a dive is allocated
Previously we only did this when we did fixup_dive(), but that way we can't reference dives "early" in their life cycle (e.g., right after they got downloaded). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/dive.c b/dive.c
index f593dde94..80aa555ee 100644
--- a/dive.c
+++ b/dive.c
@@ -221,6 +221,7 @@ struct dive *alloc_dive(void)
if (!dive)
exit(1);
memset(dive, 0, sizeof(*dive));
+ dive->id = dive_getUniqID(dive);
return dive;
}
@@ -955,7 +956,10 @@ struct dive *fixup_dive(struct dive *dive)
weightsystem_t *ws = dive->weightsystem + i;
add_weightsystem_description(ws);
}
- dive->id = dive_getUniqID(dive);
+ /* we should always have a uniq ID as that gets assigned during alloc_dive(),
+ * but we want to make sure... */
+ if (!dive->id)
+ dive->id = dive_getUniqID(dive);
return dive;
}