Skip to content

Commit d14b96b

Browse files
amomchilovjhawthorn
andcommitted
Use RUBY_DEFAULT_FREE in embedded case
Co-authored-by: John Hawthorn <john@hawthorn.email>
1 parent fc86de0 commit d14b96b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

ext/rubydex/handle.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@ static void handle_mark(void *ptr) {
1515
}
1616
}
1717

18+
#ifndef HAVE_RUBY_TYPED_EMBEDDABLE
1819
static void handle_free(void *ptr) {
1920
if (ptr) {
20-
#ifdef HAVE_RUBY_TYPED_EMBEDDABLE
21-
// The storage is embedded in the TypedData Ruby object itself.
22-
// Don't free `ptr`, because the GC will do that for us.
23-
#else
2421
xfree(ptr);
25-
#endif
2622
}
2723
}
24+
#endif
2825

2926
static const rb_data_type_t handle_type = {
3027
.wrap_struct_name = "RubydexHandle",
3128
.function = {
3229
.dmark = handle_mark,
30+
#ifdef HAVE_RUBY_TYPED_EMBEDDABLE
31+
.dfree = RUBY_DEFAULT_FREE,
32+
#else
3333
.dfree = handle_free,
34+
#endif
3435
.dsize = NULL,
3536
.dcompact = NULL,
3637
},

0 commit comments

Comments
 (0)