diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index 5ab8ae3fd3..af93252e96 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1133,15 +1133,23 @@ ossl_ssl_shutdown(SSL *ssl) } static void -ossl_ssl_free(SSL *ssl) +ossl_ssl_free(void *ssl) { SSL_free(ssl); } +const rb_data_type_t ossl_ssl_type = { + "OpenSSL/SSL", + { + 0, ossl_ssl_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + static VALUE ossl_ssl_s_alloc(VALUE klass) { - return Data_Wrap_Struct(klass, 0, ossl_ssl_free, NULL); + return TypedData_Wrap_Struct(klass, &ossl_ssl_type, NULL); } /* diff --git a/ext/openssl/ossl_ssl.h b/ext/openssl/ossl_ssl.h index faa5d3678f..0c20b10721 100644 --- a/ext/openssl/ossl_ssl.h +++ b/ext/openssl/ossl_ssl.h @@ -12,7 +12,7 @@ #define _OSSL_SSL_H_ #define GetSSL(obj, ssl) do { \ - Data_Get_Struct((obj), SSL, (ssl)); \ + TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \ } while (0) #define GetSSLSession(obj, sess) do { \ @@ -27,6 +27,7 @@ GetSSLSession((obj), (sess)); \ } while (0) +extern const rb_data_type_t ossl_ssl_type; extern const rb_data_type_t ossl_ssl_session_type; extern VALUE mSSL; extern VALUE eSSLError;