From 74616cdddfd0f46822be8708f7bad0038fdca526 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 12 Jul 2014 12:48:27 -0700 Subject: Rename event: correctly replace event with new one I don't like that the event structure includes the variable length array. That really makes it a pain to change the name of an event (on the flip side, freeing events is easier I guess). Anyway, to correctly rename an event we need to actually remove the event from the correct dc and then add a new event with the new name. The previous code was insane (it only worked if the new name was of smaller or equal length, otherwise it had a beautiful buffer overflow). And of course we need to do this both for the current_dive and the displayed_dive. Fixes #616 Signed-off-by: Dirk Hohndel --- dive.h | 1 + 1 file changed, 1 insertion(+) (limited to 'dive.h') diff --git a/dive.h b/dive.h index 871818cce..4978f4f9a 100644 --- a/dive.h +++ b/dive.h @@ -624,6 +624,7 @@ extern void fill_default_cylinder(cylinder_t *cyl); extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx); extern void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name); extern void remove_event(struct event *event); +extern void update_event_name(struct dive *d, struct event* event, char *name); extern void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *mean, int *duration); extern int get_cylinder_index(struct dive *dive, struct event *ev); extern int nr_cylinders(struct dive *dive); -- cgit v1.2.3-70-g09d2