From 85f2231b381a232686a39e4962b3d5e3cad61161 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Mon, 25 Apr 2011 00:56:55 +0930 Subject: Add support for growing strbufs exponentially - Change default to 1024 byte strings and doubling in size - Add strbuf debug statistics --- lua_json.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lua_json.c') 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) strbuf_t buf; char *json; - strbuf_init(&buf); - strbuf_set_increment(&buf, 256); + strbuf_init(&buf, 0); json_append_data(l, &buf); json = strbuf_free_to_string(&buf, len); @@ -637,8 +636,7 @@ void lua_json_decode(lua_State *l, const char *json_text) json.data = json_text; json.index = 0; - json.tmp = strbuf_new(); - strbuf_set_increment(json.tmp, 256); + json.tmp = strbuf_new(0); json_next_token(&json, &token); json_process_value(l, &json, &token); -- cgit v1.2.3-55-g6feb