summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Olivier Verstraet <O.VERSTRAET@salviadeveloppement.com>2017-05-02 08:40:16 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-04 10:37:00 -0700
commitbf373f508360a109e42f75b3eceab2277d1614e7 (patch)
tree712ee4eee508130241c4bb97e02ecb8b2c5d864b
parent499a792a03ad10e81e340d45099154041801b1b5 (diff)
downloadsubsurface-bf373f508360a109e42f75b3eceab2277d1614e7.tar.gz
Fix calculation of how many samples profile are in datatrack dive log file
-rw-r--r--core/datatrak.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/datatrak.c b/core/datatrak.c
index 15559b043..eaf78b3b7 100644
--- a/core/datatrak.c
+++ b/core/datatrak.c
@@ -639,7 +639,9 @@ bool dt_dive_parser(FILE *archivo, struct dive *dt_dive)
* 2bytes per sample plus another one each three samples. Also includes the
* bytes jumped over (22) and the nitrox (2) or O2 (3).
*/
- int samplenum = is_O2 ? (profile_length - 25) * 3 / 8 : (profile_length - 24) * 3 / 7;
+ int numerator = is_O2 ? (profile_length - 25) * 3 : (profile_length - 24) * 3;
+ int denominator = is_O2 ? 8 : 7;
+ int samplenum = (numerator / denominator) + (((numerator % denominator) != 0) ? 1 : 0);
dc->events = calloc(samplenum, sizeof(struct event));
dc->alloc_samples = samplenum;