diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-22 09:51:34 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-22 09:51:34 +0000 |
commit | d3da6ba716d94ec684186a89a52fb90636db89ee (patch) | |
tree | c653c0c7e560be2839c468f4f877f1cf47ac83c5 /vmstk.c | |
parent | 8fdd3b45c0c2b2a5751efd79e2be4cc0241af53e (diff) | |
download | rsyslog-d3da6ba716d94ec684186a89a52fb90636db89ee.tar.gz rsyslog-d3da6ba716d94ec684186a89a52fb90636db89ee.tar.xz rsyslog-d3da6ba716d94ec684186a89a52fb90636db89ee.zip |
completed initial vmstk implementation
Diffstat (limited to 'vmstk.c')
-rw-r--r-- | vmstk.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -66,7 +66,9 @@ CODESTARTobjDebugPrint(vmstk) ENDobjDebugPrint(vmstk) -/* push a value on the stack +/* push a value on the stack. The provided pVar is now owned + * by the stack. If the user intends to continue use it, it + * must be duplicated. */ static rsRetVal push(vmstk_t *pThis, var_t *pVar) @@ -76,11 +78,18 @@ push(vmstk_t *pThis, var_t *pVar) ISOBJ_TYPE_assert(pThis, vmstk); ISOBJ_TYPE_assert(pVar, var); + if(pThis->iStkPtr >= VMSTK_SIZE) + ABORT_FINALIZE(RS_RET_OUT_OF_STACKSPACE); + + pThis->vStk[pThis->iStkPtr++] = pVar; + +finalize_it: RETiRet; } /* pop a value from the stack + * The user is responsible for destructing the ppVar returned. */ static rsRetVal pop(vmstk_t *pThis, var_t **ppVar) @@ -90,6 +99,12 @@ pop(vmstk_t *pThis, var_t **ppVar) ISOBJ_TYPE_assert(pThis, vmstk); assert(ppVar != NULL); + if(pThis->iStkPtr == 0) + ABORT_FINALIZE(RS_RET_STACK_EMPTY); + + *ppVar = pThis->vStk[pThis->iStkPtr--]; + +finalize_it: RETiRet; } |