Skip to content
Browse files

Fix Atomic::InternalReference allocation

Moves the ir_alloc method to be the allocator for
Atomic::InternalReference instead of Atomic.

Fixes segfault when referencing a type that is not immediate (Fixes #11).
  • Loading branch information...
1 parent 2dc992a commit a39a90e5549c3b0f4c14726fd6a690d61d22eed8 @eric eric committed
Showing with 3 additions and 2 deletions.
  1. +3 −2 ext/atomic_reference.c
View
5 ext/atomic_reference.c
@@ -1,7 +1,7 @@
#include <ruby.h>
static void ir_mark(void *value) {
- rb_gc_mark((VALUE)value);
+ rb_gc_mark_maybe((VALUE)value);
}
static VALUE ir_alloc(VALUE klass) {
@@ -51,7 +51,8 @@ void Init_atomic_reference() {
cAtomic = rb_const_get(rb_cObject, rb_intern("Atomic"));
cInternalReference = rb_define_class_under(cAtomic, "InternalReference",
rb_cObject);
- rb_define_alloc_func(cAtomic, ir_alloc);
+
+ rb_define_alloc_func(cInternalReference, ir_alloc);
rb_define_method(cInternalReference, "initialize", ir_initialize, 1);
rb_define_method(cInternalReference, "get", ir_get, 0);

0 comments on commit a39a90e

Please sign in to comment.
Something went wrong with that request. Please try again.