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

@ -17,25 +17,23 @@ typedef struct
{
volume_t size;
pressure_t workingpressure;
const char *description; /* "LP85", "AL72", "AL80", "HP100+" or whatever */
const char *description = nullptr; /* "LP85", "AL72", "AL80", "HP100+" or whatever */
} cylinder_type_t;
typedef struct
{
cylinder_type_t type;
struct gasmix gasmix;
struct gasmix gasmix = gasmix_air;
pressure_t start, end, sample_start, sample_end;
depth_t depth;
bool manually_added;
bool manually_added = false;
volume_t gas_used;
volume_t deco_gas_used;
enum cylinderuse cylinder_use;
bool bestmix_o2;
bool bestmix_he;
enum cylinderuse cylinder_use = OC_GAS;
bool bestmix_o2 = false;
bool bestmix_he = false;
} cylinder_t;
static const cylinder_t empty_cylinder = { { { 0 }, { 0 }, (const char *)0}, { { 0 }, { 0 } } , { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, false, { 0 }, { 0 }, OC_GAS, false, false };
/* Table of cylinders. Attention: this stores cylinders,
* *not* pointers to cylinders. This has two crucial consequences:
* 1) Pointers to cylinders are not stable. They may be