Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpx/lua-cjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-05-10 17:02:01 +0400
committerMark Pulford <mark@kyne.com.au>2011-05-10 17:02:01 +0400
commit126470cc7b6c2314c02805e4d00afe04b6b00312 (patch)
tree9dd59bcc02307403410ef405b0f02bf39bd57560 /strbuf.c
parentc877da6c1f84b19cd2e7e8154b4a0d0e355745a0 (diff)
Add runtime option for persistent encode buffer
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/strbuf.c b/strbuf.c
index 7a53a52..a850d41 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -99,12 +99,16 @@ static inline void debug_stats(strbuf_t *s)
}
}
+/* If strbuf_t has not been dynamically allocated, strbuf_free() can
+ * be called any number of times strbuf_init() */
void strbuf_free(strbuf_t *s)
{
debug_stats(s);
- if (s->buf)
+ if (s->buf) {
free(s->buf);
+ s->buf = NULL;
+ }
if (s->dynamic)
free(s);
}