1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| #define ASSERT(expr) ((void) 0)
/* local function prototypes */
static GCLIST_MEMBER *gc_lookupEntry(
GCLIST *pList,
GCLIST_MEMBER *pEntry);
static GCLIST_MEMBER *gc_getPrevious(
GCLIST *pList,
GCLIST_MEMBER *pEntry);
/* function: gc_lookupEntry
* purpose: Lookup specified entry to make sure it is in the list
*/
static GCLIST_MEMBER *gc_lookupEntry(
GCLIST *pList,
GCLIST_MEMBER *pEntry)
{
GCLIST_MEMBER *pEntry1 = pList->pFirst;
while((pEntry1 != NULL) && (pEntry1 != pEntry))
{
pEntry1 = pEntry1->pNext;
}
return(pEntry1);
}
/* function: gc_getPrevious
* purpose: Get the previous entry in the list
*/
static GCLIST_MEMBER *gc_getPrevious(
GCLIST *pList,
GCLIST_MEMBER *pEntry)
{
GCLIST_MEMBER *pMember = pList->pFirst;
GCLIST_MEMBER *pNextMember = pMember->pNext;
while((pNextMember != NULL)
&& (pNextMember != pEntry))
{
pMember = pNextMember;
pNextMember = pMember->pNext;
}
if(pNextMember != pEntry)
{
return(NULL);
}
return(pMember);
}
/* function: gc_list_initialize */
void gc_list_initialize(
GCLIST *pList)
{
pList->size = 0;
pList->pFirst = NULL;
pList->pLast = NULL;
}
/* function: gc_list_destroy */
void gc_list_destroy(
GCLIST *pList,
GCLIST_FREE_FUNC pFreeFunc)
{
GCLIST_MEMBER *pEntry;
while((pEntry = gc_list_getEntry(pList, 0U)) != NULL)
{
if (gc_list_removeEntry(pList, pEntry))
{
if(pFreeFunc != NULL)
{
pFreeFunc(pEntry);
}
}
}
} |