From 6cd85d9b731ef646b605d483dbbcddbc70283338 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 1 Jun 2015 23:13:51 -0300 Subject: Simplify model handling and crashes fixes So, there's only one crash left (that I put a big TODO: on the maintab.cpp about) and I'll fix it tomorrow as it's quite late here and I'm almost sleeping at the keyboard. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- divelist.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'divelist.c') diff --git a/divelist.c b/divelist.c index d57188a68..773f52713 100644 --- a/divelist.c +++ b/divelist.c @@ -341,6 +341,19 @@ int get_divenr(struct dive *dive) return -1; } +int get_divesite_idx(struct dive_site *ds) +{ + int i; + struct dive_site *d; + // tempting as it may be, don't die when called with dive=NULL + if (ds) + for_each_dive_site(i, d) { + if (d->uuid == ds->uuid) // don't compare pointers, we could be passing in a copy of the dive + return i; + } + return -1; +} + static struct gasmix air = { .o2.permille = O2_IN_AIR, .he.permille = 0 }; /* take into account previous dives until there is a 48h gap between dives */ -- cgit v1.2.3-70-g09d2