summaryrefslogtreecommitdiffstats
path: root/linkedlist.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-31 12:34:45 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-31 12:34:45 +0000
commit19e94f195997a4907f96b5d53e88c2f5c44b08e0 (patch)
tree33a30dc9cf3fec14d340f4944a42773fe0ae708c /linkedlist.c
parent6465202ed784cdb02339af7760bac09c8e3556c2 (diff)
downloadrsyslog-19e94f195997a4907f96b5d53e88c2f5c44b08e0.tar.gz
rsyslog-19e94f195997a4907f96b5d53e88c2f5c44b08e0.tar.xz
rsyslog-19e94f195997a4907f96b5d53e88c2f5c44b08e0.zip
prepared cfsysline.c for integration into output modules
Diffstat (limited to 'linkedlist.c')
-rw-r--r--linkedlist.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/linkedlist.c b/linkedlist.c
index 1238ea08..a75652a5 100644
--- a/linkedlist.c
+++ b/linkedlist.c
@@ -40,13 +40,15 @@
/* Initialize an existing linkedList_t structure
+ * pKey destructor may be zero to take care of non-keyed lists.
*/
-rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*, void*))
+rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*), rsRetVal (*pKeyDestructor)(void*))
{
assert(pThis != NULL);
assert(pEltDestructor != NULL);
pThis->pEltDestruct = pEltDestructor;
+ pThis->pKeyDestruct = pKeyDestructor;
pThis->cmpOp = NULL;
pThis->pKey = NULL;
pThis->iNumElts = 0;
@@ -74,7 +76,10 @@ rsRetVal llDestroy(linkedList_t *pThis)
/* we ignore errors during destruction, as we need to try
* finish the linked list in any case.
*/
- pThis->pEltDestruct(pEltPrev->pData, pEltPrev->pKey);
+ if(pEltPrev->pData != NULL)
+ pThis->pEltDestruct(pEltPrev->pData);
+ if(pEltPrev->pKey != NULL)
+ pThis->pKeyDestruct(pEltPrev->pKey);
free(pEltPrev);
}