aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_x509ext.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/ossl_x509ext.c')
-rw-r--r--ext/openssl/ossl_x509ext.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/ext/openssl/ossl_x509ext.c b/ext/openssl/ossl_x509ext.c
index 48625f85..faffe06a 100644
--- a/ext/openssl/ossl_x509ext.c
+++ b/ext/openssl/ossl_x509ext.c
@@ -14,10 +14,10 @@
if (!(ext)) { \
ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
} \
- (obj) = Data_Wrap_Struct((klass), 0, X509_EXTENSION_free, (ext)); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509ext_type, (ext)); \
} while (0)
#define GetX509Ext(obj, ext) do { \
- Data_Get_Struct((obj), X509_EXTENSION, (ext)); \
+ TypedData_Get_Struct((obj), X509_EXTENSION, &ossl_x509ext_type, (ext)); \
if (!(ext)) { \
ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
} \
@@ -30,10 +30,10 @@
if (!((ctx) = OPENSSL_malloc(sizeof(X509V3_CTX)))) \
ossl_raise(rb_eRuntimeError, "CTX wasn't allocated!"); \
X509V3_set_ctx((ctx), NULL, NULL, NULL, NULL, 0); \
- (obj) = Data_Wrap_Struct((klass), 0, ossl_x509extfactory_free, (ctx)); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509extfactory_type, (ctx)); \
} while (0)
#define GetX509ExtFactory(obj, ctx) do { \
- Data_Get_Struct((obj), X509V3_CTX, (ctx)); \
+ TypedData_Get_Struct((obj), X509V3_CTX, &ossl_x509extfactory_type, (ctx)); \
if (!(ctx)) { \
ossl_raise(rb_eRuntimeError, "CTX wasn't initialized!"); \
} \
@@ -46,6 +46,20 @@ VALUE cX509Ext;
VALUE cX509ExtFactory;
VALUE eX509ExtError;
+static void
+ossl_x509ext_free(void *ptr)
+{
+ X509_EXTENSION_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509ext_type = {
+ "OpenSSL/X509/EXTENSION",
+ {
+ 0, ossl_x509ext_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
/*
* Public
*/
@@ -98,11 +112,19 @@ DupX509ExtPtr(VALUE obj)
* Ext factory
*/
static void
-ossl_x509extfactory_free(X509V3_CTX *ctx)
+ossl_x509extfactory_free(void *ctx)
{
OPENSSL_free(ctx);
}
+static const rb_data_type_t ossl_x509extfactory_type = {
+ "OpenSSL/X509/EXTENSION/Factory",
+ {
+ 0, ossl_x509extfactory_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
static VALUE
ossl_x509extfactory_alloc(VALUE klass)
{