diff options
author | Zachary Scott <e@zzak.io> | 2015-06-03 14:02:14 -0400 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2015-06-03 14:02:14 -0400 |
commit | 8706e768540ab7d556f1859f71d7ee3c8b40e25d (patch) | |
tree | 53b7f857ccada137d2678adaf0a5408873d35809 /ext/openssl/ossl_x509attr.c | |
parent | bd594af66966d8ab62e6963540b2caabc0cf3087 (diff) | |
download | ruby-openssl-8706e768540ab7d556f1859f71d7ee3c8b40e25d.tar.gz |
Upstream ruby/ruby@451fe26 from r50673
Diffstat (limited to 'ext/openssl/ossl_x509attr.c')
-rw-r--r-- | ext/openssl/ossl_x509attr.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c index ee10dd85..10e511d2 100644 --- a/ext/openssl/ossl_x509attr.c +++ b/ext/openssl/ossl_x509attr.c @@ -10,11 +10,13 @@ */ #include "ossl.h" -#define WrapX509Attr(klass, obj, attr) do { \ +#define NewX509Attr(klass) \ + TypedData_Wrap_Struct((klass), &ossl_x509attr_type, 0) +#define SetX509Attr(obj, attr) do { \ if (!(attr)) { \ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \ } \ - (obj) = TypedData_Wrap_Struct((klass), &ossl_x509attr_type, (attr)); \ + RTYPEDDATA_DATA(obj) = (attr); \ } while (0) #define GetX509Attr(obj, attr) do { \ TypedData_Get_Struct((obj), X509_ATTRIBUTE, &ossl_x509attr_type, (attr)); \ @@ -56,6 +58,7 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr) X509_ATTRIBUTE *new; VALUE obj; + obj = NewX509Attr(cX509Attr); if (!attr) { new = X509_ATTRIBUTE_new(); } else { @@ -64,7 +67,7 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr) if (!new) { ossl_raise(eX509AttrError, NULL); } - WrapX509Attr(cX509Attr, obj, new); + SetX509Attr(obj, new); return obj; } @@ -91,9 +94,10 @@ ossl_x509attr_alloc(VALUE klass) X509_ATTRIBUTE *attr; VALUE obj; + obj = NewX509Attr(klass); if (!(attr = X509_ATTRIBUTE_new())) ossl_raise(eX509AttrError, NULL); - WrapX509Attr(klass, obj, attr); + SetX509Attr(obj, attr); return obj; } |