From 8706e768540ab7d556f1859f71d7ee3c8b40e25d Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Wed, 3 Jun 2015 14:02:14 -0400 Subject: Upstream ruby/ruby@451fe26 from r50673 --- ext/openssl/ossl_x509store.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'ext/openssl/ossl_x509store.c') diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c index 9924f863..fbb83159 100644 --- a/ext/openssl/ossl_x509store.c +++ b/ext/openssl/ossl_x509store.c @@ -10,11 +10,13 @@ */ #include "ossl.h" -#define WrapX509Store(klass, obj, st) do { \ +#define NewX509Store(klass) \ + TypedData_Wrap_Struct((klass), &ossl_x509store_type, 0) +#define SetX509Store(obj, st) do { \ if (!(st)) { \ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \ } \ - (obj) = TypedData_Wrap_Struct((klass), &ossl_x509store_type, (st)); \ + RTYPEDDATA_DATA(obj) = (st); \ } while (0) #define GetX509Store(obj, st) do { \ TypedData_Get_Struct((obj), X509_STORE, &ossl_x509store_type, (st)); \ @@ -27,11 +29,13 @@ GetX509Store((obj), (st)); \ } while (0) -#define WrapX509StCtx(klass, obj, ctx) do { \ +#define NewX509StCtx(klass) \ + TypedData_Wrap_Struct((klass), &ossl_x509stctx_type, 0) +#define SetX509StCtx(obj, ctx) do { \ if (!(ctx)) { \ ossl_raise(rb_eRuntimeError, "STORE_CTX wasn't initialized!"); \ } \ - (obj) = TypedData_Wrap_Struct((klass), &ossl_x509stctx_type, (ctx)); \ + RTYPEDDATA_DATA(obj) = (ctx); \ } while (0) #define GetX509StCtx(obj, ctx) do { \ TypedData_Get_Struct((obj), X509_STORE_CTX, &ossl_x509stctx_type, (ctx)); \ @@ -73,7 +77,8 @@ ossl_x509store_new(X509_STORE *store) { VALUE obj; - WrapX509Store(cX509Store, obj, store); + obj = NewX509Store(cX509Store); + SetX509Store(obj, store); return obj; } @@ -108,10 +113,11 @@ ossl_x509store_alloc(VALUE klass) X509_STORE *store; VALUE obj; + obj = NewX509Store(klass); if((store = X509_STORE_new()) == NULL){ ossl_raise(eX509StoreError, NULL); } - WrapX509Store(klass, obj, store); + SetX509Store(obj, store); return obj; } @@ -373,7 +379,8 @@ ossl_x509stctx_new(X509_STORE_CTX *ctx) { VALUE obj; - WrapX509StCtx(cX509StoreContext, obj, ctx); + obj = NewX509StCtx(cX509StoreContext); + SetX509StCtx(obj, ctx); return obj; } @@ -407,10 +414,11 @@ ossl_x509stctx_alloc(VALUE klass) X509_STORE_CTX *ctx; VALUE obj; + obj = NewX509StCtx(klass); if((ctx = X509_STORE_CTX_new()) == NULL){ ossl_raise(eX509StoreError, NULL); } - WrapX509StCtx(klass, obj, ctx); + SetX509StCtx(obj, ctx); return obj; } -- cgit v1.2.3