diff --git a/src/ioc/misc/iocInit.c b/src/ioc/misc/iocInit.c index 0268801cb..774846848 100644 --- a/src/ioc/misc/iocInit.c +++ b/src/ioc/misc/iocInit.c @@ -659,6 +659,7 @@ int iocShutdown(void) callbackShutdown(); iterateRecords(doFreeRecord, NULL); asShutdown(); + iocshFree(); iocState = iocStopped; return 0; } diff --git a/src/libCom/iocsh/iocsh.cpp b/src/libCom/iocsh/iocsh.cpp index 81727696b..671239781 100644 --- a/src/libCom/iocsh/iocsh.cpp +++ b/src/libCom/iocsh/iocsh.cpp @@ -203,20 +203,22 @@ void epicsShareAPI iocshRegisterVariable (const iocshVarDef *piocshVarDef) */ void epicsShareAPI iocshFree(void) { - struct iocshCommand *pc, *nc; - struct iocshVariable *pv, *nv; + struct iocshCommand *pc; + struct iocshVariable *pv; iocshTableLock (); for (pc = iocshCommandHead ; pc != NULL ; ) { - nc = pc->next; + struct iocshCommand * nc = pc->next; free (pc); pc = nc; } for (pv = iocshVariableHead ; pv != NULL ; ) { - nv = pv->next; + struct iocshVariable *nv = pv->next; free (pv); pv = nv; } + iocshCommandHead = NULL; + iocshVariableHead = NULL; iocshTableUnlock (); }