diff options
author | Zachary Scott <e@zzak.io> | 2015-01-05 11:59:50 -0800 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2015-01-05 11:59:50 -0800 |
commit | 2953dfd4ad925a669110fed1993d6e83b24e420f (patch) | |
tree | 05e4d2a6750e0ce6dd408c2b8f2f5bf597cfe54a /ext/openssl/ossl_x509store.c | |
parent | 77269de78e376981342127d30dc0b953b9bcd781 (diff) | |
download | ruby-openssl-2953dfd4ad925a669110fed1993d6e83b24e420f.tar.gz |
Sync with ruby trunk
Diffstat (limited to 'ext/openssl/ossl_x509store.c')
-rw-r--r-- | ext/openssl/ossl_x509store.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c index dd924bf9..3093e28a 100644 --- a/ext/openssl/ossl_x509store.c +++ b/ext/openssl/ossl_x509store.c @@ -14,10 +14,10 @@ if (!(st)) { \ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \ } \ - (obj) = Data_Wrap_Struct((klass), 0, X509_STORE_free, (st)); \ + (obj) = TypedData_Wrap_Struct((klass), &ossl_x509store_type, (st)); \ } while (0) #define GetX509Store(obj, st) do { \ - Data_Get_Struct((obj), X509_STORE, (st)); \ + TypedData_Get_Struct((obj), X509_STORE, &ossl_x509store_type, (st)); \ if (!(st)) { \ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \ } \ @@ -31,10 +31,10 @@ if (!(ctx)) { \ ossl_raise(rb_eRuntimeError, "STORE_CTX wasn't initialized!"); \ } \ - (obj) = Data_Wrap_Struct((klass), 0, ossl_x509stctx_free, (ctx)); \ + (obj) = TypedData_Wrap_Struct((klass), &ossl_x509stctx_type, (ctx)); \ } while (0) #define GetX509StCtx(obj, ctx) do { \ - Data_Get_Struct((obj), X509_STORE_CTX, (ctx)); \ + TypedData_Get_Struct((obj), X509_STORE_CTX, &ossl_x509stctx_type, (ctx)); \ if (!(ctx)) { \ ossl_raise(rb_eRuntimeError, "STORE_CTX is out of scope!"); \ } \ @@ -51,6 +51,20 @@ VALUE cX509Store; VALUE cX509StoreContext; VALUE eX509StoreError; +static void +ossl_x509store_free(void *ptr) +{ + X509_STORE_free(ptr); +} + +static const rb_data_type_t ossl_x509store_type = { + "OpenSSL/X509/STORE", + { + 0, ossl_x509store_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + /* * Public functions */ @@ -342,7 +356,17 @@ ossl_x509store_verify(int argc, VALUE *argv, VALUE self) /* * Public Functions */ -static void ossl_x509stctx_free(X509_STORE_CTX*); +static void ossl_x509stctx_free(void*); + + +static const rb_data_type_t ossl_x509stctx_type = { + "OpenSSL/X509/STORE_CTX", + { + 0, ossl_x509stctx_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + VALUE ossl_x509stctx_new(X509_STORE_CTX *ctx) @@ -367,8 +391,9 @@ ossl_x509stctx_clear_ptr(VALUE obj) * Private functions */ static void -ossl_x509stctx_free(X509_STORE_CTX *ctx) +ossl_x509stctx_free(void *ptr) { + X509_STORE_CTX *ctx = ptr; if(ctx->untrusted) sk_X509_pop_free(ctx->untrusted, X509_free); if(ctx->cert) |