From b8897cd60fa27ed391672bf2298603e67c2f6186 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 12 Dec 2014 22:37:55 +0000 Subject: ossl_pkcs7.c: typed data * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_pkcs7.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ext/openssl') diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c index f476807fb7..060d30bc06 100644 --- a/ext/openssl/ossl_pkcs7.c +++ b/ext/openssl/ossl_pkcs7.c @@ -14,10 +14,10 @@ if (!(pkcs7)) { \ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \ } \ - (obj) = Data_Wrap_Struct((klass), 0, PKCS7_free, (pkcs7)); \ + (obj) = TypedData_Wrap_Struct((klass), &ossl_pkcs7_type, (pkcs7)); \ } while (0) #define GetPKCS7(obj, pkcs7) do { \ - Data_Get_Struct((obj), PKCS7, (pkcs7)); \ + TypedData_Get_Struct((obj), PKCS7, &ossl_pkcs7_type, (pkcs7)); \ if (!(pkcs7)) { \ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \ } \ @@ -76,6 +76,20 @@ VALUE cPKCS7Signer; VALUE cPKCS7Recipient; VALUE ePKCS7Error; +static void +ossl_pkcs7_free(void *ptr) +{ + PKCS7_free(ptr); +} + +static const rb_data_type_t ossl_pkcs7_type = { + "OpenSSL/PKCS7", + { + 0, ossl_pkcs7_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + /* * Public * (MADE PRIVATE UNTIL SOMEBODY WILL NEED THEM) -- cgit v1.2.3