From a8f6758ab09fb839a5d52acdf536ca06cc05e20f Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 7 May 2014 16:41:28 -0700 Subject: add hack to try to avoid garbage collection --- ext/ffi_yajl/ext/parser/parser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/ffi_yajl/ext/parser/parser.c b/ext/ffi_yajl/ext/parser/parser.c index 543701e..9256469 100644 --- a/ext/ffi_yajl/ext/parser/parser.c +++ b/ext/ffi_yajl/ext/parser/parser.c @@ -167,6 +167,10 @@ static VALUE mParser_do_yajl_parse(VALUE self, VALUE str, VALUE opts) { ctx.stack = rb_ary_new(); ctx.key_stack = rb_ary_new(); + /* hack to avoid garbage collection */ + rb_ivar_set(self, rb_intern("stack"), ctx.stack); + rb_ivar_set(self, rb_intern("key_stack"), ctx.key_stack); + hand = yajl_alloc(&callbacks, NULL, &ctx); if ((stat = yajl_parse(hand, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str))) != yajl_status_ok) { err = yajl_get_error(hand, 1, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str)); -- cgit v1.2.1