From 457cd40f30593b982d8f8933ab4d62949b372616 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 12 Dec 2014 21:58:22 +0000 Subject: ossl_ocsp.c: typed data * ext/openssl/ossl_ocsp.c (ossl_ocsp_certid_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_ocsp.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c index fbe8ebf60b..dc31d79cf7 100644 --- a/ext/openssl/ossl_ocsp.c +++ b/ext/openssl/ossl_ocsp.c @@ -54,10 +54,10 @@ #define WrapOCSPCertId(klass, obj, cid) do { \ if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \ - (obj) = Data_Wrap_Struct((klass), 0, OCSP_CERTID_free, (cid)); \ + (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_certid_type, (cid)); \ } while (0) #define GetOCSPCertId(obj, cid) do { \ - Data_Get_Struct((obj), OCSP_CERTID, (cid)); \ + TypedData_Get_Struct((obj), OCSP_CERTID, &ossl_ocsp_certid_type, (cid)); \ if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \ } while (0) #define SafeGetOCSPCertId(obj, cid) do { \ @@ -114,6 +114,20 @@ static const rb_data_type_t ossl_ocsp_basicresp_type = { 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, }; +static void +ossl_ocsp_certid_free(void *ptr) +{ + OCSP_CERTID_free(ptr); +} + +static const rb_data_type_t ossl_ocsp_certid_type = { + "OpenSSL/OCSP/CERTID", + { + 0, ossl_ocsp_certid_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + /* * Public */ -- cgit v1.2.3