mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: convert sample.c to C++ and add default constructor
This changes default behavior when creating a sample struct in C++ code: it is now initialized to default values. If this ever turns out to be a performance problem, we can either add additional constructors or use special functions that do not initialize memory, such as make_unique_for_overwrite. This removes non-standard (respectively >C++20) constructs, namely designated initializers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f47196087e
commit
c8c533e791
5 changed files with 30 additions and 6 deletions
|
@ -1337,7 +1337,7 @@ static void merge_one_sample(const struct sample *sample, int time, struct divec
|
|||
* a minute apart, and shallower than 5m
|
||||
*/
|
||||
if (time > last_time + 60 && last_depth < 5000) {
|
||||
struct sample surface = { 0 };
|
||||
struct sample surface;
|
||||
|
||||
/* Init a few values from prev sample to avoid useless info in XML */
|
||||
surface.bearing.degrees = prev->bearing.degrees;
|
||||
|
@ -1388,7 +1388,7 @@ static void merge_samples(struct divecomputer *res,
|
|||
for (;;) {
|
||||
int j;
|
||||
int at, bt;
|
||||
struct sample sample = { .ndl{ -1 } , .bearing{ -1 } };
|
||||
struct sample sample;
|
||||
|
||||
if (!res)
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue