diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2019-11-24 14:44:05 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2019-11-24 14:44:05 -0500 |
| commit | ff7e486b9d7084973124e9805e302377bf2f4415 (patch) | |
| tree | 5029b2e3b96c1b946b5a07e0f8cd44ffb59da453 /src | |
| parent | d917129d502a753f13bd26ecf47a30d31f738fc1 (diff) | |
| download | libctemplates-ff7e486b9d7084973124e9805e302377bf2f4415.tar.gz libctemplates-ff7e486b9d7084973124e9805e302377bf2f4415.tar.bz2 libctemplates-ff7e486b9d7084973124e9805e302377bf2f4415.zip | |
Reset the output buffer on render
Reset the output buffer when TMPL_render() is called so that only only
the latest render errors are preserved.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ctemplates.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ctemplates.c b/src/ctemplates.c index fb055e6..74d6098 100644 --- a/src/ctemplates.c +++ b/src/ctemplates.c @@ -1257,9 +1257,15 @@ TMPL_render_helper(struct TMPL_templates* t, struct TMPL_varlist* varlist){ char* TMPL_render(struct TMPL_templates* t, struct TMPL_varlist* varlist, size_t* size_p){ int err; + /*Reset the output buffer*/ if(t->out != NULL){ free_tmpl_buf(t->out); } + /*Reset the error buffer, if needed*/ + if(t->errout != NULL && t->errout->total_len > 0){ + free_tmpl_buf(t->errout); + t->errout = alloc_tmpl_buf(); + } t->out = alloc_tmpl_buf(); t->cursor = t->roottag; err = TMPL_render_helper(t,varlist); |
