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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-19 13:21:22 +02:00 committed by bstoeger
parent f120fecccb
commit 8ddc960fa0
3 changed files with 1 additions and 26 deletions

View file

@ -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)) {

View file

@ -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);

View file

@ -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",