aboutsummaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-31 16:33:20 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-31 16:33:20 -0700
commit00d798854aa2594b819f50dc135efca96a93adb9 (patch)
tree7ffccc25fb47c287c7677fc965d29c4e5ae69913 /dive.h
parentc17300cfaa7dcc95b70112281491b8fb1a530f8e (diff)
downloadsubsurface-00d798854aa2594b819f50dc135efca96a93adb9.tar.gz
Start cleaning up dive accessors
I'm going to add a menu to import (and eventually export) dives, and so we'd like to be able to start out with no dives at all. Right now we croak if that happens - it's not like the code has been written with actual end users in mind. So start cleaning things up. First make the 'current_dive' macro work right even for invalid dives. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index a8e3c319a..23e2f544c 100644
--- a/dive.h
+++ b/dive.h
@@ -121,6 +121,13 @@ struct dive_table {
extern struct dive_table dive_table;
+static inline struct dive *get_dive(unsigned int nr)
+{
+ if (nr >= dive_table.nr)
+ return NULL;
+ return dive_table.dives[nr];
+}
+
extern void parse_xml_init(void);
extern void parse_xml_file(const char *filename);