Skip to content

Commit

Permalink
Fix compatibility with newer digest gems (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot authored Dec 29, 2024
1 parent e1766cf commit 9278714
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*.gem
*.log
*.rbc
*.bundle
*.bundle.dSYM
/.config
/.rake_tasks~
/coverage/
Expand Down
1 change: 1 addition & 0 deletions ext/digest/extconf.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ def have_func!(header, *args)
have_header! "string.h"

have_func! "rb_str_set_len"
have_func "rb_digest_make_metadata", "ruby/digest.h"

create_makefile "digest/keccak" or exit 1
4 changes: 4 additions & 0 deletions ext/digest/keccak.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ Init_keccak() {

cKeccak = rb_define_class_under(mDigest, "Keccak", cDigest_Base);

#ifdef HAVE_RB_DIGEST_MAKE_METADATA
rb_iv_set(cKeccak, "metadata", rb_digest_make_metadata(&keccak));
#else
rb_iv_set(cKeccak, "metadata", Data_Wrap_Struct(0, 0, 0, (void *)&keccak));
#endif

rb_define_method(cKeccak, "initialize", rb_keccak_initialize, -1);
rb_define_method(cKeccak, "digest_length", rb_keccak_digest_length, 0);
Expand Down

0 comments on commit 9278714

Please sign in to comment.