Sha256: 9492e9a3ffaa57e62b4aa4dbdb222a320b06abbf0ecac4a35ef1324c28ecd32d
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
#include <stdlib.h> #include <assert.h> #define INIT_ENV_DEPTH 256 static void tagstack_init(struct tagstack* tagstack) { tagstack->depth=INIT_ENV_DEPTH; tagstack->pos=-1; tagstack->entry=(struct tagstack_entry*) malloc (tagstack->depth * sizeof(struct tagstack_entry)); } static void tagstack_free(struct tagstack* tagstack) { tagstack->depth=-1; tagstack->pos=-1; free(tagstack->entry); } static int tagstack_notempty(struct tagstack* tagstack) { return tagstack->pos>=0; } /* static void tagstack_entry_debug(struct tagstack_entry item) { tmpl_log(TMPL_LOG_DEBUG,"vcontext = %d value=%d\n",item.vcontext,item.value); } */ static struct tagstack_entry* tagstack_top(struct tagstack* tagstack) { return tagstack->entry+tagstack->pos; } static struct tagstack_entry tagstack_pop(struct tagstack* tagstack) { if (tagstack->pos<0) { tmpl_log(TMPL_LOG_ERROR,"stack underflow:tags stack is empty\n"); tagstack->pos=0; if (tagstack->depth<0) { tmpl_log(TMPL_LOG_ERROR,"FATAL:stack error:tags stack is uninitialized\n"); tagstack_init(tagstack); } } return *(tagstack->entry+ tagstack->pos--); } static void tagstack_push(struct tagstack* tagstack, struct tagstack_entry item) { /* overflow check */ if (++(tagstack->pos)>=tagstack->depth) { if (tagstack->depth<INIT_ENV_DEPTH) tagstack->depth=INIT_ENV_DEPTH; tagstack->depth*=2; tagstack->entry=(struct tagstack_entry*) realloc (tagstack->entry, tagstack->depth * sizeof(struct tagstack_entry)); } *(tagstack->entry+tagstack->pos)=item; } /* * Local Variables: * mode: c * End: */
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
html-template-pro-0.0.3 | ext/html/template/tagstack.inc |
html-template-pro-0.0.2 | ext/html/template/internal/tagstack.inc |
html-template-pro-0.0.1 | ext/html/template/internal/tagstack.inc |