ruby-changes:36729
From: nobu <ko1@a...>
Date: Sat, 13 Dec 2014 08:39:10 +0900 (JST)
Subject: [ruby-changes:36729] nobu:r48810 (trunk): ossl_x509cert.c: typed data
nobu 2014-12-13 08:38:55 +0900 (Sat, 13 Dec 2014) New Revision: 48810 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48810 Log: ossl_x509cert.c: typed data * ext/openssl/ossl_x509cert.c (ossl_x509_type): use typed data. Modified files: trunk/ext/openssl/ossl_x509cert.c Index: ext/openssl/ossl_x509cert.c =================================================================== --- ext/openssl/ossl_x509cert.c (revision 48809) +++ ext/openssl/ossl_x509cert.c (revision 48810) @@ -14,10 +14,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509cert.c#L14 if (!(x509)) { \ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \ } \ - (obj) = Data_Wrap_Struct((klass), 0, X509_free, (x509)); \ + (obj) = TypedData_Wrap_Struct((klass), &ossl_x509_type, (x509)); \ } while (0) #define GetX509(obj, x509) do { \ - Data_Get_Struct((obj), X509, (x509)); \ + TypedData_Get_Struct((obj), X509, &ossl_x509_type, (x509)); \ if (!(x509)) { \ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \ } \ @@ -33,6 +33,20 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509cert.c#L33 VALUE cX509Cert; VALUE eX509CertError; +static void +ossl_x509_free(void *ptr) +{ + X509_free(ptr); +} + +static const rb_data_type_t ossl_x509_type = { + "OpenSSL/X509", + { + 0, ossl_x509_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + /* * Public */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/