diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-21 14:59:18 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-21 14:59:18 +0000 |
commit | 2d5d05e7c5d3c2c3e1575ae7e240492f7df34256 (patch) | |
tree | cbf6cd6b6bde716e7f55de1a3bb6944afc0093b0 /ctok_token.c | |
parent | 45136c665690534d934d0c0c188dbb18a0131b96 (diff) | |
download | rsyslog-2d5d05e7c5d3c2c3e1575ae7e240492f7df34256.tar.gz rsyslog-2d5d05e7c5d3c2c3e1575ae7e240492f7df34256.tar.xz rsyslog-2d5d05e7c5d3c2c3e1575ae7e240492f7df34256.zip |
changed tokenizer to utilize var class instead of scalar types
Diffstat (limited to 'ctok_token.c')
-rw-r--r-- | ctok_token.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/ctok_token.c b/ctok_token.c index a7acabd2..13a39a54 100644 --- a/ctok_token.c +++ b/ctok_token.c @@ -34,11 +34,18 @@ /* static data */ DEFobjStaticHelpers +DEFobjCurrIf(var) /* Standard-Constructor */ BEGINobjConstruct(ctok_token) /* be sure to specify the object type also in END macro! */ + /* TODO: we may optimize the code below and alloc var only if actually + * needed (but we need it quite often) + */ + CHKiRet(var.Construct(&pThis->pVar)); + CHKiRet(var.ConstructFinalize(pThis->pVar)); +finalize_it: ENDobjConstruct(ctok_token) @@ -55,8 +62,8 @@ rsRetVal ctok_tokenConstructFinalize(ctok_token_t __attribute__((unused)) *pThis /* destructor for the ctok object */ BEGINobjDestruct(ctok_token) /* be sure to specify the object type also in END and CODESTART macros! */ CODESTARTobjDestruct(ctok_token) - if(pThis->pstrVal != NULL) { - rsCStrDestruct(&pThis->pstrVal); + if(pThis->pVar != NULL) { + var.Destruct(&pThis->pVar); } ENDobjDestruct(ctok_token) @@ -67,15 +74,15 @@ ENDobjDestruct(ctok_token) * rgerhards, 2008-02-20 */ static rsRetVal -ctok_tokenUnlinkCStr(ctok_token_t *pThis, cstr_t **ppCStr) +ctok_tokenUnlinkVar(ctok_token_t *pThis, var_t **ppVar) { DEFiRet; ISOBJ_TYPE_assert(pThis, ctok_token); - ASSERT(ppCStr != NULL); + ASSERT(ppVar != NULL); - *ppCStr = pThis->pstrVal; - pThis->pstrVal = NULL; + *ppVar = pThis->pVar; + pThis->pVar = NULL; RETiRet; } @@ -106,13 +113,16 @@ CODESTARTobjQueryInterface(ctok_token) pIf->Construct = ctok_tokenConstruct; pIf->ConstructFinalize = ctok_tokenConstructFinalize; pIf->Destruct = ctok_tokenDestruct; - pIf->UnlinkCStr = ctok_tokenUnlinkCStr; + pIf->UnlinkVar = ctok_tokenUnlinkVar; pIf->IsCmpOp = ctok_tokenIsCmpOp; finalize_it: ENDobjQueryInterface(ctok_token) BEGINObjClassInit(ctok_token, 1) /* class, version */ + /* request objects we use */ + CHKiRet(objUse(var)); + OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, ctok_tokenConstructFinalize); ENDObjClassInit(ctok_token) |