From 8ddc960fa009c883bb930a64addf1b12fe14aa92 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 19 May 2024 13:21:22 +0200 Subject: [PATCH] core: remove update_event_name Since the name of an event is not incorporated into the even structure anymore, we don't need these shenanigans. Just assign the event name. Signed-off-by: Berthold Stoeger --- core/dive.cpp | 24 ------------------------ core/dive.h | 1 - smtk-import/smartrak.cpp | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/core/dive.cpp b/core/dive.cpp index 3e827dd73..d509d24ad 100644 --- a/core/dive.cpp +++ b/core/dive.cpp @@ -130,30 +130,6 @@ void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int second add_event_to_dc(dc, ev); } -/* 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, int dc_number, struct event *event, const 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); - invalidate_dive_cache(d); -} - struct gasmix get_gasmix_from_event(const struct dive *dive, const struct event *ev) { if (ev && event_is_gaschange(ev)) { diff --git a/core/dive.h b/core/dive.h index 9f81005d3..31d139a6f 100644 --- a/core/dive.h +++ b/core/dive.h @@ -191,7 +191,6 @@ extern bool is_cylinder_used(const struct dive *dive, int idx); extern bool is_cylinder_prot(const struct dive *dive, int idx); extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx); extern struct event *create_gas_switch_event(struct dive *dive, struct divecomputer *dc, int seconds, int idx); -extern void update_event_name(struct dive *d, int dc_number, struct event *event, const char *name); extern void per_cylinder_mean_depth(const struct dive *dive, struct divecomputer *dc, int *mean, int *duration); extern int get_cylinder_index(const struct dive *dive, const struct event *ev); extern struct gasmix get_gasmix_from_event(const struct dive *, const struct event *ev); diff --git a/smtk-import/smartrak.cpp b/smtk-import/smartrak.cpp index dd2f10b2c..ba4a1fce3 100644 --- a/smtk-import/smartrak.cpp +++ b/smtk-import/smartrak.cpp @@ -765,7 +765,7 @@ static void smtk_parse_bookmarks(MdbHandle *mdb, struct dive *d, char *dive_idx) const char *tmp = table.get_data(2); ev = find_bookmark(d->dc.events, time); if (ev) - update_event_name(d, 0, ev, tmp); + ev->name = tmp; else if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp)) report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s",