mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allocate dive samples separately from 'struct dive'
We used to avoid some extra allocations by just allocating the dive samples as part of the 'struct dive' allocation itself, but that ends up complicating things, and will make it impossible to have multiple different sets of samples (for multiple dive computers). So stop doing it. Just allocate the dive samples array separately. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
10ce60e212
commit
a9786564c2
7 changed files with 45 additions and 66 deletions
6
uemis.c
6
uemis.c
|
@ -185,8 +185,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
|
|||
uint8_t *data;
|
||||
struct sample *sample;
|
||||
uemis_sample_t *u_sample;
|
||||
struct dive **divep = datap;
|
||||
struct dive *dive = *divep;
|
||||
struct dive *dive = datap;
|
||||
int template, gasoffset;
|
||||
|
||||
in_deco = FALSE;
|
||||
|
@ -236,8 +235,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
|
|||
* duration in the header is a) in minutes and b) up to 3 minutes short */
|
||||
if (u_sample->dive_time > dive->duration.seconds + 180)
|
||||
break;
|
||||
sample = prepare_sample(divep);
|
||||
dive = *divep; /* prepare_sample might realloc the dive */
|
||||
sample = prepare_sample(dive);
|
||||
sample->time.seconds = u_sample->dive_time;
|
||||
sample->depth.mm = rel_mbar_to_depth(u_sample->water_pressure, dive);
|
||||
sample->temperature.mkelvin = (u_sample->dive_temperature * 100) + 273150;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue