summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 23:38:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 23:38:55 +0000
commit3bc78d5bd8c70daf7cfbfba0d9583497e0c9651c (patch)
tree5fd43322b35e9455b0938be2abb56322515c1a98
parentc3fdb1c3bd7ccf213a9bff384c85b11487093a9e (diff)
ossl_x509cert.c: typed data
* ext/openssl/ossl_x509cert.c (ossl_x509_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/openssl/ossl_x509cert.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index 0c8f075..b76ea79 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -14,10 +14,10 @@
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 @@
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
*/