core: default initialize units-type objects to 0

Makes the code much nicer to read.

Default initialize cylinder_t to the empty cylinder.

This produces lots of warnings, because most structure are now
not PODs anymore and shouldn't be erased using memset().

These memset()s will be removed one-by-one and replaced by
proper constructors.

The whole ordeal made it necessary to add a constructor to
struct event. To simplify things the whole optimization of
the variable-size event names was removed. In upcoming commits
this will be replaced by std::string anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-04 19:15:47 +02:00 committed by bstoeger
parent b82fdd1d20
commit 408b31b6ce
34 changed files with 128 additions and 148 deletions

View file

@ -97,13 +97,6 @@ stats_summary calculate_stats_summary(bool selected_only)
int current_month = 0;
int prev_month = 0, prev_year = 0;
dive_trip_t *trip_ptr = nullptr;
//stats_t stats = { 0 };
//if (divelog.dives->nr > 0) {
// stats.shortest_time.seconds = divelog.dives->dives[0]->duration.seconds;
// stats.min_depth.mm = divelog.dives->dives[0]->maxdepth.mm;
// stats.selection_size = divelog.dives->nr;
//}
stats_summary out;
@ -318,7 +311,7 @@ bool is_cylinder_prot(const struct dive *dive, int idx)
/* Returns a vector with dive->cylinders.nr entries */
std::vector<volume_t> get_gas_used(struct dive *dive)
{
std::vector<volume_t> gases(dive->cylinders.nr, volume_t { 0 });
std::vector<volume_t> gases(dive->cylinders.nr);
for (int idx = 0; idx < dive->cylinders.nr; idx++) {
cylinder_t *cyl = get_cylinder(dive, idx);
pressure_t start, end;
@ -351,7 +344,7 @@ std::pair<volume_t, volume_t> selected_dives_gas_parts()
{
int i;
struct dive *d;
volume_t o2_tot = { 0 }, he_tot = { 0 };
volume_t o2_tot, he_tot;
for_each_dive (i, d) {
if (!d->selected || d->invalid)
continue;