summaryrefslogtreecommitdiffstats
path: root/linkedlist.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-31 15:23:28 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-31 15:23:28 +0000
commit074ece90c0b7f32307716eeb6d0308b83197b6ce (patch)
tree707340dde192c4c4ac8b196f6da2d26bbfc22247 /linkedlist.c
parent7449e8356b19900acaa33e387bd4ea65ba85e204 (diff)
downloadrsyslog-074ece90c0b7f32307716eeb6d0308b83197b6ce.tar.gz
rsyslog-074ece90c0b7f32307716eeb6d0308b83197b6ce.tar.xz
rsyslog-074ece90c0b7f32307716eeb6d0308b83197b6ce.zip
- got the basic code in place to create an in-memory list of cfsysline
handlers (omfile.c used as testing case) -- not yet in active code
Diffstat (limited to 'linkedlist.c')
-rw-r--r--linkedlist.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/linkedlist.c b/linkedlist.c
index a75652a5..0a798efb 100644
--- a/linkedlist.c
+++ b/linkedlist.c
@@ -42,14 +42,14 @@
/* 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*), rsRetVal (*pKeyDestructor)(void*))
+rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*), rsRetVal (*pKeyDestructor)(void*), int pCmpOp())
{
assert(pThis != NULL);
assert(pEltDestructor != NULL);
pThis->pEltDestruct = pEltDestructor;
pThis->pKeyDestruct = pKeyDestructor;
- pThis->cmpOp = NULL;
+ pThis->cmpOp = pCmpOp;
pThis->pKey = NULL;
pThis->iNumElts = 0;
pThis->pRoot = NULL;
@@ -110,7 +110,6 @@ rsRetVal llGetNextElt(linkedList_t *pThis, linkedListCookie_t *ppElt, void **ppU
if(pElt == NULL) {
iRet = RS_RET_END_OF_LINKEDLIST;
} else {
- pElt = pThis->pRoot;
*ppUsr = pElt->pData;
}
@@ -120,6 +119,19 @@ rsRetVal llGetNextElt(linkedList_t *pThis, linkedListCookie_t *ppElt, void **ppU
}
+/* return the key of an Elt
+ */
+rsRetVal llGetKey(llElt_t *pThis, void **ppData)
+{
+ assert(pThis != NULL);
+ assert(ppData != NULL);
+
+ *ppData = pThis->pKey;
+
+ return RS_RET_OK;
+}
+
+
/* construct a new llElt_t
*/
static rsRetVal llEltConstruct(llElt_t **ppThis, void *pKey, void *pData)
@@ -148,6 +160,7 @@ finalize_it:
rsRetVal llAppend(linkedList_t *pThis, void *pKey, void *pData)
{
llElt_t *pElt;
+llElt_t *pEltPrev = pThis->pLast;
DEFiRet;
CHKiRet(llEltConstruct(&pElt, pKey, pData));
@@ -159,6 +172,7 @@ rsRetVal llAppend(linkedList_t *pThis, void *pKey, void *pData)
pThis->pLast->pNext = pElt;
}
pThis->pLast = pElt;
+printf("llAppend pThis 0x%x, pLastPrev 0x%x, pLast 0x%x, pElt 0x%x\n", pThis, pEltPrev, pThis->pLast, pElt);
finalize_it:
return iRet;