diff options
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -75,6 +75,29 @@ void remove_event(struct event* event) } } +/* since the name is an array as part of the structure (how silly is that?) we + * have to actually remove the existing event and replace it with a new one. + * WARNING, WARNING... this may end up freeing event in case that event is indeed + * WARNING, WARNING... part of this divecomputer on this dive! */ +void update_event_name(struct dive *d, struct event* event, char *name) +{ + if (!d || !event) + return; + struct divecomputer *dc = get_dive_dc(d, dc_number); + if (!dc) + return; + struct event **removep = &dc->events; + struct event *remove; + while ((*removep)->next && !same_event(*removep, event)) + removep = &(*removep)->next; + if (!same_event(*removep, event)) + return; + remove = *removep; + *removep = (*removep)->next; + add_event(dc, event->time.seconds, event->type, event->flags, event->value, name); + free(remove); +} + /* this returns a pointer to static variable - so use it right away after calling */ struct gasmix *get_gasmix_from_event(struct event *ev) { |