summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-19 14:23:29 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-19 20:12:59 +0900
commit4059180ef275e527b33c2b3d7153adcc24d82096 (patch)
tree3cf10bd840d2add5a4e381217fbe3510f6758adb /dive.h
parent5e3f7ba22fe2dcb8af597d011bba16b3a7317c2a (diff)
downloadsubsurface-4059180ef275e527b33c2b3d7153adcc24d82096.tar.gz
Add new helper function that looks up the index of a dive by its uniq ID
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index 3cb3a9980..d371b1508 100644
--- a/dive.h
+++ b/dive.h
@@ -454,6 +454,24 @@ static inline struct dive *get_dive_by_uniq_id(int id)
return dive;
}
+static inline int get_idx_by_uniq_id(int id)
+{
+ int i;
+ struct dive *dive = NULL;
+
+ for_each_dive(i, dive) {
+ if (dive->id == id)
+ break;
+ }
+#ifdef DEBUG
+ if(dive == NULL){
+ fprintf(stderr, "Invalid id %x passed to get_dive_by_diveid, try to fix the code\n", id);
+ exit(1);
+ }
+#endif
+ return i;
+}
+
#ifdef __cplusplus
extern "C" {
#endif