Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ext/fiddle/closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ closure_memsize(const void * ptr)
}

const rb_data_type_t closure_data_type = {
"fiddle/closure",
{0, dealloc, closure_memsize,},
0, 0,
RUBY_TYPED_FREE_IMMEDIATELY,
.wrap_struct_name = "fiddle/closure",
.function = {
.dmark = 0,
.dfree = dealloc,
.dsize = closure_memsize
},
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};

struct callback_args {
Expand Down
9 changes: 7 additions & 2 deletions ext/fiddle/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ function_memsize(const void *p)
}

const rb_data_type_t function_data_type = {
"fiddle/function",
{0, deallocate, function_memsize,},
.wrap_struct_name = "fiddle/function",
.function = {
.dmark = 0,
.dfree = deallocate,
.dsize = function_memsize
},
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};

static VALUE
Expand Down
9 changes: 7 additions & 2 deletions ext/fiddle/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ fiddle_handle_memsize(const void *ptr)
}

static const rb_data_type_t fiddle_handle_data_type = {
"fiddle/handle",
{0, fiddle_handle_free, fiddle_handle_memsize,},
.wrap_struct_name = "fiddle/handle",
.function = {
.dmark = 0,
.dfree = fiddle_handle_free,
.dsize = fiddle_handle_memsize
},
.flags = RUBY_TYPED_WB_PROTECTED,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we specify RUBY_TYPED_FREE_IMMEDIATELY here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe?

The reason I didn't add it is that the dfree function calls dlclose and I don't know all the characteristics of it, so I don't know if it's safe to call from the GC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

I think that we can add it after we improve Fiddle::Handle#[] to refer Fiddle::Handle from the returned symbol. We can ensure keeping Fiddle::Handle while its symbols are referred.

};

/*
Expand Down