summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-05-07 16:41:28 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-05-07 16:41:28 -0700
commita8f6758ab09fb839a5d52acdf536ca06cc05e20f (patch)
tree78dbba9ad384fcfa4168dfd8ae1d254dabd9723a /ext
parent5b24d1b2887ff8d44d231119cc162f706aa768cd (diff)
downloadffi-yajl-a8f6758ab09fb839a5d52acdf536ca06cc05e20f.tar.gz
add hack to try to avoid garbage collection
Diffstat (limited to 'ext')
-rw-r--r--ext/ffi_yajl/ext/parser/parser.c4
1 files changed, 4 insertions, 0 deletions
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));