Make DEVNUM robust against double initialization.

This commit is contained in:
Holger Vogt 2019-10-05 11:28:17 +02:00
parent e0448b4f37
commit 60a3298c2e
1 changed files with 4 additions and 1 deletions

View File

@ -244,6 +244,7 @@ spice_destroy_devices(void)
tfree(DEVicesfl); tfree(DEVicesfl);
#endif #endif
tfree(DEVices); tfree(DEVices);
DEVNUM = 0;
} }
@ -251,9 +252,11 @@ void
spice_init_devices(void) spice_init_devices(void)
{ {
int i; int i;
/* Safeguard against double initialization */
DEVNUM = NUMELEMS(static_devices);
#ifdef XSPICE #ifdef XSPICE
/*Initilise the structs and add digital node type */ /* Initialize the structs and add digital node type */
g_evt_udn_info = TMALLOC(Evt_Udn_Info_t *, 1); g_evt_udn_info = TMALLOC(Evt_Udn_Info_t *, 1);
g_evt_num_udn_types = 1; g_evt_num_udn_types = 1;
g_evt_udn_info[0] = &idn_digital_info; g_evt_udn_info[0] = &idn_digital_info;