diff --git a/src/libCom/ellLib.c b/src/libCom/ellLib.c index c95fc692d..91a5c8304 100644 --- a/src/libCom/ellLib.c +++ b/src/libCom/ellLib.c @@ -28,16 +28,21 @@ * ----------------- * .01 jrw 07-02-92 created * .02 rcz 08-26-92 moved to libCom + * .03 joh 12-12-97 added ellverify() */ /* #define DEBUG_DRIVER */ + + #ifdef vxWorks #include #endif #include +#include + #define epicsExportSharedSymbols #include "ellLib.h" @@ -487,6 +492,43 @@ ELLLIST *pList; return; } + + /**************************************************************************** + * + * This function verifies that the list is consistent. + * joh 12-12-97 + * + *****************************************************************************/ +void epicsShareAPI ellVerify (ELLLIST *pList) +{ + ELLNODE *pNode; + ELLNODE *pNext; + int count; + + assert (pList); + + count = 0u; + pNode = ellFirst(pList); + if (pNode) { + assert (ellPrevious(pNode)==NULL); + while (1) { + count++; + pNext = ellNext(pNode); + if (pNext) { + assert (ellPrevious(pNext)==pNode); + } + else { + break; + } + pNode = pNext; + } + assert (ellNext(pNode)==NULL); + } + + assert (pNode==ellLast(pList)); + assert (count==ellCount(pList)); +} + #ifdef DEBUG_DRIVER /**************************************************************************** * diff --git a/src/libCom/ellLib.h b/src/libCom/ellLib.h index 519151872..8db17270d 100644 --- a/src/libCom/ellLib.h +++ b/src/libCom/ellLib.h @@ -29,6 +29,7 @@ * .01 jrw 07-02-92 created * .02 rcz 07-23-93 changed name * .03 rcz 07-26-93 changed name again + * .04 joh 12-12-97 added ellverify() */ #ifndef INCellLibh #define INCellLibh @@ -92,6 +93,7 @@ epicsShareFunc ELLNODE * epicsShareAPI ellNth (ELLLIST *pList, int nodeNum); epicsShareFunc ELLNODE * epicsShareAPI ellNStep (ELLNODE *pNode, int nStep); epicsShareFunc int epicsShareAPI ellFind (ELLLIST *pList, ELLNODE *pNode); epicsShareFunc void epicsShareAPI ellFree (ELLLIST *pList); +epicsShareFunc void epicsShareAPI ellVerify (ELLLIST *pList); #else /*__STDC__*/ @@ -132,6 +134,8 @@ epicsShareFunc ELLNODE * epicsShareAPI ellNth (); epicsShareFunc ELLNODE * epicsShareAPI ellNStep (); epicsShareFunc int epicsShareAPI ellFind (); epicsShareFunc void epicsShareAPI ellFree (); +epicsShareFunc void ellVerify (); + #endif /*__STDC__*/ #ifdef __cplusplus diff --git a/src/libCom/ellLib/ellLib.c b/src/libCom/ellLib/ellLib.c index c95fc692d..91a5c8304 100644 --- a/src/libCom/ellLib/ellLib.c +++ b/src/libCom/ellLib/ellLib.c @@ -28,16 +28,21 @@ * ----------------- * .01 jrw 07-02-92 created * .02 rcz 08-26-92 moved to libCom + * .03 joh 12-12-97 added ellverify() */ /* #define DEBUG_DRIVER */ + + #ifdef vxWorks #include #endif #include +#include + #define epicsExportSharedSymbols #include "ellLib.h" @@ -487,6 +492,43 @@ ELLLIST *pList; return; } + + /**************************************************************************** + * + * This function verifies that the list is consistent. + * joh 12-12-97 + * + *****************************************************************************/ +void epicsShareAPI ellVerify (ELLLIST *pList) +{ + ELLNODE *pNode; + ELLNODE *pNext; + int count; + + assert (pList); + + count = 0u; + pNode = ellFirst(pList); + if (pNode) { + assert (ellPrevious(pNode)==NULL); + while (1) { + count++; + pNext = ellNext(pNode); + if (pNext) { + assert (ellPrevious(pNext)==pNode); + } + else { + break; + } + pNode = pNext; + } + assert (ellNext(pNode)==NULL); + } + + assert (pNode==ellLast(pList)); + assert (count==ellCount(pList)); +} + #ifdef DEBUG_DRIVER /**************************************************************************** * diff --git a/src/libCom/ellLib/ellLib.h b/src/libCom/ellLib/ellLib.h index 519151872..8db17270d 100644 --- a/src/libCom/ellLib/ellLib.h +++ b/src/libCom/ellLib/ellLib.h @@ -29,6 +29,7 @@ * .01 jrw 07-02-92 created * .02 rcz 07-23-93 changed name * .03 rcz 07-26-93 changed name again + * .04 joh 12-12-97 added ellverify() */ #ifndef INCellLibh #define INCellLibh @@ -92,6 +93,7 @@ epicsShareFunc ELLNODE * epicsShareAPI ellNth (ELLLIST *pList, int nodeNum); epicsShareFunc ELLNODE * epicsShareAPI ellNStep (ELLNODE *pNode, int nStep); epicsShareFunc int epicsShareAPI ellFind (ELLLIST *pList, ELLNODE *pNode); epicsShareFunc void epicsShareAPI ellFree (ELLLIST *pList); +epicsShareFunc void epicsShareAPI ellVerify (ELLLIST *pList); #else /*__STDC__*/ @@ -132,6 +134,8 @@ epicsShareFunc ELLNODE * epicsShareAPI ellNth (); epicsShareFunc ELLNODE * epicsShareAPI ellNStep (); epicsShareFunc int epicsShareAPI ellFind (); epicsShareFunc void epicsShareAPI ellFree (); +epicsShareFunc void ellVerify (); + #endif /*__STDC__*/ #ifdef __cplusplus