smtk-import rework smtk_build_tank_info()

The cylinder info is built one by one. This way, instead of passing dive
and tank number parameters, just passing a pointer to the tank been
worked seems preferable.

It also introduces lrint() in the function to round the doubles values
obtained from libmdb for tank size and workingpressure.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
This commit is contained in:
Salvador Cuñat 2017-03-16 16:55:40 +01:00 committed by Dirk Hohndel
parent 36658d87f3
commit 20b348579b

View file

@ -396,7 +396,7 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, timestamp_t when, uin
free(str);
}
static void smtk_build_tank_info(MdbHandle *mdb, struct dive *dive, int tanknum, char *idx)
static void smtk_build_tank_info(MdbHandle *mdb, cylinder_t *tank, char *idx)
{
MdbTableDef *table;
MdbColumn *col[MDB_MAX_COLS];
@ -409,9 +409,9 @@ static void smtk_build_tank_info(MdbHandle *mdb, struct dive *dive, int tanknum,
for (i = 1; i <= atoi(idx); i++)
mdb_fetch_row(table);
dive->cylinder[tanknum].type.description = copy_string(col[1]->bind_ptr);
dive->cylinder[tanknum].type.size.mliter = strtod(col[2]->bind_ptr, NULL) * 1000;
dive->cylinder[tanknum].type.workingpressure.mbar = strtod(col[4]->bind_ptr, NULL) * 1000;
tank->type.description = copy_string(col[1]->bind_ptr);
tank->type.size.mliter = lrint(strtod(col[2]->bind_ptr, NULL) * 1000);
tank->type.workingpressure.mbar = lrint(strtod(col[4]->bind_ptr, NULL) * 1000);
smtk_free(bound_values, table->num_cols);
mdb_free_tabledef(table);