aboutsummaryrefslogtreecommitdiffstats
path: root/core/equipment.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-12-11 22:34:35 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-13 11:49:59 -0800
commit50b11024d685129e78c36313b892dbc0e55c654c (patch)
tree96d56180e18ae2e11a7e4f3a6d86944883738797 /core/equipment.h
parent2e328c7633c1de43af000fd6506385c651365a0d (diff)
downloadsubsurface-50b11024d685129e78c36313b892dbc0e55c654c.tar.gz
core: keep tank infos in a dynamic table
The list of known tank types were kept in a fixed size table. Instead, use a dynamic table with our horrendous table macros. This is more flexible and sensible. While doing this, clean up the TankInfoModel, which was leaking memory. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/equipment.h')
-rw-r--r--core/equipment.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/equipment.h b/core/equipment.h
index 96cc43f1f..8f7cee74a 100644
--- a/core/equipment.h
+++ b/core/equipment.h
@@ -68,7 +68,6 @@ struct weightsystem_table {
weightsystem_t *weightsystems;
};
-#define MAX_TANK_INFO (100)
#define MAX_WS_INFO (100)
extern int cylinderuse_from_text(const char *text);
@@ -110,11 +109,21 @@ extern void add_cylinder(struct cylinder_table *, int idx, cylinder_t cyl);
void get_gas_string(struct gasmix gasmix, char *text, int len);
const char *gasname(struct gasmix gasmix);
-struct tank_info_t {
+typedef struct tank_info {
const char *name;
int cuft, ml, psi, bar;
+} tank_info_t;
+
+struct tank_info_table {
+ int nr, allocated;
+ struct tank_info *infos;
};
-extern struct tank_info_t tank_info[MAX_TANK_INFO];
+
+extern struct tank_info_table tank_info_table;
+extern void reset_tank_info_table(struct tank_info_table *table);
+extern void clear_tank_info_table(struct tank_info_table *table);
+extern void add_tank_info_metric(struct tank_info_table *table, const char *name, int ml, int bar);
+extern void add_tank_info_imperial(struct tank_info_table *table, const char *name, int cuft, int psi);
struct ws_info_t {
const char *name;