mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
2e328c7633
commit
50b11024d6
12 changed files with 154 additions and 141 deletions
|
@ -130,14 +130,12 @@ static int dtrak_prepare_data(int model, device_data_t *dev_data)
|
|||
*/
|
||||
static const char *cyl_type_by_size(int size)
|
||||
{
|
||||
struct tank_info_t *ti = tank_info;
|
||||
|
||||
while (ti->ml != size && ti < tank_info + MAX_TANK_INFO)
|
||||
ti++;
|
||||
if (ti == tank_info + MAX_TANK_INFO)
|
||||
return "";
|
||||
else
|
||||
return ti->name;
|
||||
for (int i = 0; i < tank_info_table.nr; ++i) {
|
||||
const struct tank_info *ti = &tank_info_table.infos[i];
|
||||
if (ti->ml == size)
|
||||
return ti->name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue