mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add new helper function that looks up the index of a dive by its uniq ID
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5e3f7ba22f
commit
4059180ef2
1 changed files with 18 additions and 0 deletions
18
dive.h
18
dive.h
|
@ -454,6 +454,24 @@ static inline struct dive *get_dive_by_uniq_id(int id)
|
||||||
return dive;
|
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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue