summaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/divelist.c b/divelist.c
index 28d082029..9a1ab017f 100644
--- a/divelist.c
+++ b/divelist.c
@@ -368,10 +368,12 @@ static void add_dive_to_deco(struct dive *dive)
int get_divenr(struct dive *dive)
{
- int divenr = -1;
- while (++divenr < dive_table.nr && get_dive(divenr) != dive)
- ;
- return divenr;
+ int i;
+ struct dive *d;
+ for_each_dive(i, d)
+ if (d == dive)
+ return i;
+ return -1;
}
static struct gasmix air = { .o2.permille = O2_IN_AIR };
@@ -787,8 +789,8 @@ struct dive *merge_two_dives(struct dive *a, struct dive *b)
if (!a || !b)
return NULL;
- i = get_index_for_dive(a);
- j = get_index_for_dive(b);
+ i = get_divenr(a);
+ j = get_divenr(b);
res = merge_dives(a, b, b->when - a->when, FALSE);
if (!res)
return NULL;