aboutsummaryrefslogtreecommitdiff
path: root/lua_json.c
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-04-25 00:56:55 +0930
committerMark Pulford <mark@kyne.com.au>2011-04-25 00:56:55 +0930
commit85f2231b381a232686a39e4962b3d5e3cad61161 (patch)
treea4f91a37496af94a7bbfcdac268296e9dbb2679b /lua_json.c
parent2b693fb4493764e71f11b6257c0ce58cdbb8a779 (diff)
downloadlua-cjson-85f2231b381a232686a39e4962b3d5e3cad61161.tar.gz
lua-cjson-85f2231b381a232686a39e4962b3d5e3cad61161.tar.bz2
lua-cjson-85f2231b381a232686a39e4962b3d5e3cad61161.zip
Add support for growing strbufs exponentially
- Change default to 1024 byte strings and doubling in size - Add strbuf debug statistics
Diffstat (limited to 'lua_json.c')
-rw-r--r--lua_json.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lua_json.c b/lua_json.c
index 25078a3..10810f0 100644
--- a/lua_json.c
+++ b/lua_json.c
@@ -247,8 +247,7 @@ char *lua_json_encode(lua_State *l, int *len)
247 strbuf_t buf; 247 strbuf_t buf;
248 char *json; 248 char *json;
249 249
250 strbuf_init(&buf); 250 strbuf_init(&buf, 0);
251 strbuf_set_increment(&buf, 256);
252 json_append_data(l, &buf); 251 json_append_data(l, &buf);
253 json = strbuf_free_to_string(&buf, len); 252 json = strbuf_free_to_string(&buf, len);
254 253
@@ -637,8 +636,7 @@ void lua_json_decode(lua_State *l, const char *json_text)
637 636
638 json.data = json_text; 637 json.data = json_text;
639 json.index = 0; 638 json.index = 0;
640 json.tmp = strbuf_new(); 639 json.tmp = strbuf_new(0);
641 strbuf_set_increment(json.tmp, 256);
642 640
643 json_next_token(&json, &token); 641 json_next_token(&json, &token);
644 json_process_value(l, &json, &token); 642 json_process_value(l, &json, &token);