Fix HASHSZ in register.c and make a hash collision fatal

pull/224/head
Michael Black 2020-03-12 09:07:48 -05:00
rodzic 7685613310
commit 30e4f472f5
1 zmienionych plików z 8 dodań i 10 usunięć

Wyświetl plik

@ -156,7 +156,9 @@ struct rig_list
};
#define RIGLSTHASHSZ 16
// This size has to be > than the max# of rigs for any manufacturer
// A fatal error will occur when running rigctl if this value is too small
#define RIGLSTHASHSZ 256
#define HASH_FUNC(a) ((a)%RIGLSTHASHSZ)
@ -190,15 +192,6 @@ int HAMLIB_API rig_register(const struct rig_caps *caps)
__func__,
caps->rig_model);
#ifndef DONT_WANT_DUP_CHECK
if (rig_get_caps(caps->rig_model) != NULL)
{
return -RIG_EINVAL;
}
#endif
p = (struct rig_list *)malloc(sizeof(struct rig_list));
if (!p)
@ -207,6 +200,11 @@ int HAMLIB_API rig_register(const struct rig_caps *caps)
}
hval = HASH_FUNC(caps->rig_model);
if(rig_hash_table[hval])
{
printf("Hash collision!!! Fatal error!!\n");
exit(1);
}
p->caps = caps;
// p->handle = NULL;
p->next = rig_hash_table[hval];