summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-21 12:06:02 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-22 07:28:27 +0900
commitef4705070ff67322386041529b7f10eaf09f6cdf (patch)
treefaabcc792bd3d5e9bd3338b77ce6df4fc217ca77 /dive.c
parent3750d55665e6cb940e22b5556a65078940169c5f (diff)
downloadsubsurface-ef4705070ff67322386041529b7f10eaf09f6cdf.tar.gz
Create a 'remove_event' function that removes an event.
The logic of removing the event was in the UI, and this makes the code harder to test because we need to take into account also the events that the interface is receiving, instead of only relying on the algorithm to test. so, now it lives in dive.h/.c and a unittest is easyer to make. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index d9943c23f..7e211f163 100644
--- a/dive.c
+++ b/dive.c
@@ -65,6 +65,17 @@ void add_event(struct divecomputer *dc, int time, int type, int flags, int value
remember_event(name);
}
+void remove_event(struct event* event)
+{
+ struct event **ep = &current_dc->events;
+ while (ep && *ep != event)
+ ep = &(*ep)->next;
+ if (ep) {
+ *ep = event->next;
+ free(event);
+ }
+}
+
int get_pressure_units(unsigned int mb, const char **units)
{
int pressure;