From 4cfafe0883da22cc020bb4e92d652ce16500b104 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Tue, 3 May 2011 19:47:50 +0930 Subject: Add strbuf_reset() to reset string length Add strbuf_reset() to reset string length and hide the string implementation. --- lua_cjson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua_cjson.c') diff --git a/lua_cjson.c b/lua_cjson.c index df3b71c..39e22ad 100644 --- a/lua_cjson.c +++ b/lua_cjson.c @@ -558,7 +558,7 @@ static int json_encode(lua_State *l) /* Reset persistent encode_buf. Avoids temporary allocation * for a single call. */ - cfg->encode_buf.length = 0; + strbuf_reset(&cfg->encode_buf); json_append_data(l, cfg, &cfg->encode_buf); json = strbuf_string(&cfg->encode_buf, &len); @@ -683,7 +683,7 @@ static void json_next_string_token(json_parse_t *json, json_token_t *token) /* json->tmp is the temporary strbuf used to accumulate the * decoded string value. */ - json->tmp->length = 0; + strbuf_reset(json->tmp); while ((ch = json->data[json->index]) != '"') { if (!ch) { /* Premature end of the string */ -- cgit v1.2.3-55-g6feb