diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-05 19:26:48 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-07 13:11:53 +0300 |
commit | 920ff15f7160cfa6ed8d8d81e0c156dd1d7b27c6 (patch) | |
tree | 6764713b16bf31fc7a2c17f837e5b038a3427e4f /core/dive.h | |
parent | 450f0992a09b5ef8cc1aa1df5eafd6826e03c4b8 (diff) | |
download | subsurface-920ff15f7160cfa6ed8d8d81e0c156dd1d7b27c6.tar.gz |
Planner: don't return static data in fake_dc()
fake_dc() used to return a statically allocated dc with statically
allocated samples. This is of course a questionable practice in
the light of multi-threading / resource ownership. Once these
problems were recognized, the parameter "alloc" was added. If set
to true, the function would still return a statically allocated
dc, but heap-allocated samples, which could then be copied in
a different dc.
All in all an ownership nightmare and a recipie for disaster.
The returned static dc was only used as a pointer to the samples
anyway. There are four callers of fake_dc() and they all have access
to a dc-structure without samples. Therefore, change the semantics
of fake_dc() to fill out the passed in dc. If the caller does
not care about the samples, it can simply reset the sample number
to zero after work.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.h')
-rw-r--r-- | core/dive.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/dive.h b/core/dive.h index 795203545..854ec82ba 100644 --- a/core/dive.h +++ b/core/dive.h @@ -792,6 +792,7 @@ extern struct dive *clone_dive(struct dive *s); extern void clear_table(struct dive_table *table); +extern void alloc_samples(struct divecomputer *dc, int num); extern struct sample *prepare_sample(struct divecomputer *dc); extern void finish_sample(struct divecomputer *dc); extern void add_sample_pressure(struct sample *sample, int sensor, int mbar); |