equipment: use MAX_TANK_INFO in equipment.c

MAX_TANK_INFO is defined in dive.h but is not
used in add_cylinder_description() or when
allocating 'tank_info'.

Use MAX_TANK_INFO instead of the literal 100.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2018-06-19 04:02:02 +03:00 committed by Dirk Hohndel
parent 06a870c232
commit 9e58e6f0e6

View file

@ -24,11 +24,11 @@ void add_cylinder_description(cylinder_type_t *type)
desc = type->description;
if (!desc)
return;
for (i = 0; i < 100 && tank_info[i].name != NULL; i++) {
for (i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) {
if (strcmp(tank_info[i].name, desc) == 0)
return;
}
if (i < 100) {
if (i < MAX_TANK_INFO) {
// FIXME: leaked on exit
tank_info[i].name = strdup(desc);
tank_info[i].ml = type->size.mliter;
@ -120,7 +120,7 @@ bool no_weightsystems(weightsystem_t *ws)
* we should pick up any other names from the dive
* logs directly.
*/
struct tank_info_t tank_info[100] = {
struct tank_info_t tank_info[MAX_TANK_INFO] = {
/* Need an empty entry for the no-cylinder case */
{ "", },