summaryrefslogtreecommitdiff
path: root/src/yajl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/yajl.c')
-rw-r--r--src/yajl.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/yajl.c b/src/yajl.c
index d477893..65fc123 100644
--- a/src/yajl.c
+++ b/src/yajl.c
@@ -68,7 +68,7 @@ yajl_alloc(const yajl_callbacks * callbacks,
hand->callbacks = callbacks;
hand->ctx = ctx;
- hand->lexer = NULL;
+ hand->lexer = NULL;
hand->bytesConsumed = 0;
hand->decodeBuf = yajl_buf_alloc(&(hand->alloc));
hand->flags = 0;
@@ -78,6 +78,26 @@ yajl_alloc(const yajl_callbacks * callbacks,
return hand;
}
+void
+yajl_reset(yajl_handle h)
+{
+ // reset the state stack to start
+ yajl_bs_flush(h->stateStack);
+ yajl_bs_push(h->stateStack, yajl_state_start);
+
+ // reset bytesConsumed
+ h->bytesConsumed = 0;
+
+ // clear decoding buf (note: not strictly neccesary, as
+ // this buffer is cleared on demand and reused)
+ yajl_buf_clear(h->decodeBuf);
+
+ // reset lexer state
+ if (h->lexer != NULL) {
+ yajl_lex_reset(h->lexer);
+ }
+}
+
int
yajl_config(yajl_handle h, yajl_option opt, ...)
{