Skip to content

Commit

Permalink
Add version guards for rb_hash_new_capa()
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Aug 2, 2023
1 parent e6c6b96 commit 961a8a7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions optional/capi/ext/hash_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ VALUE hash_spec_rb_hash_new(VALUE self) {
return rb_hash_new();
}

#ifdef RUBY_VERSION_IS_3_2
VALUE hash_spec_rb_hash_new_capa(VALUE self, VALUE capacity) {
return rb_hash_new_capa(NUM2LONG(capacity));
}
#endif

VALUE rb_ident_hash_new(void); /* internal.h, used in ripper */

Expand Down Expand Up @@ -153,7 +155,9 @@ void Init_hash_spec(void) {
rb_define_method(cls, "rb_hash_lookup2", hash_spec_rb_hash_lookup2, 3);
rb_define_method(cls, "rb_hash_lookup2_default_undef", hash_spec_rb_hash_lookup2_default_undef, 2);
rb_define_method(cls, "rb_hash_new", hash_spec_rb_hash_new, 0);
#ifdef RUBY_VERSION_IS_3_2
rb_define_method(cls, "rb_hash_new_capa", hash_spec_rb_hash_new_capa, 1);
#endif
rb_define_method(cls, "rb_ident_hash_new", hash_spec_rb_ident_hash_new, 0);
rb_define_method(cls, "rb_hash_size", hash_spec_rb_hash_size, 1);
rb_define_method(cls, "rb_hash_set_ifnone", hash_spec_rb_hash_set_ifnone, 2);
Expand Down

0 comments on commit 961a8a7

Please sign in to comment.