cleanup: break out event-related code into event.[c|h]

In an effort to reduce the size of dive.h and dive.c, break out
the event related functions. Moreover event-names were handled
by the profile-code, collect that also in the new source files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-10-25 09:14:16 +01:00 committed by Dirk Hohndel
parent d82a7b8b73
commit 8212acc992
26 changed files with 234 additions and 187 deletions

View file

@ -9,9 +9,10 @@
#include <assert.h>
#include "dive.h"
#include "subsurface-string.h"
#include "display.h"
#include "divelist.h"
#include "event.h"
#include "subsurface-string.h"
#include "profile.h"
#include "gaspressures.h"
@ -115,41 +116,6 @@ int get_maxdepth(const struct plot_info *pi)
return md;
}
/* collect all event names and whether we display them */
struct ev_select *ev_namelist;
int evn_allocated;
int evn_used;
void clear_events(void)
{
for (int i = 0; i < evn_used; i++)
free(ev_namelist[i].ev_name);
evn_used = 0;
}
void remember_event(const char *eventname)
{
int i = 0, len;
if (!eventname || (len = strlen(eventname)) == 0)
return;
while (i < evn_used) {
if (!strncmp(eventname, ev_namelist[i].ev_name, len))
return;
i++;
}
if (evn_used == evn_allocated) {
evn_allocated += 10;
ev_namelist = realloc(ev_namelist, evn_allocated * sizeof(struct ev_select));
if (!ev_namelist)
/* we are screwed, but let's just bail out */
return;
}
ev_namelist[evn_used].ev_name = strdup(eventname);
ev_namelist[evn_used].plot_ev = true;
evn_used++;
}
/* UNUSED! */
static int get_local_sac(struct plot_info *pi, int idx1, int idx2, struct dive *dive) __attribute__((unused));