aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_hmac.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 21:57:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-12 21:57:56 +0000
commitc5de5573c129284bba0c116bef1c58947895c25f (patch)
tree79b1e6b201034ef867bc53d478e037a0e7b2293f /ext/openssl/ossl_hmac.c
parentb0a379e3b0bd6d04a8ccf1f33a329f9c14b749c1 (diff)
downloadruby-c5de5573c129284bba0c116bef1c58947895c25f.tar.gz
ossl_hmac.c: typed data
* ext/openssl/ossl_hmac.c (ossl_hmac_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_hmac.c')
-rw-r--r--ext/openssl/ossl_hmac.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index 516e3ed8cf..74fc962b2a 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -13,9 +13,9 @@
#include "ossl.h"
#define MakeHMAC(obj, klass, ctx) \
- (obj) = Data_Make_Struct((klass), HMAC_CTX, 0, ossl_hmac_free, (ctx))
+ (obj) = TypedData_Make_Struct((klass), HMAC_CTX, &ossl_hmac_type, (ctx))
#define GetHMAC(obj, ctx) do { \
- Data_Get_Struct((obj), HMAC_CTX, (ctx)); \
+ TypedData_Get_Struct((obj), HMAC_CTX, &ossl_hmac_type, (ctx)); \
if (!(ctx)) { \
ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
} \
@@ -39,12 +39,20 @@ VALUE eHMACError;
* Private
*/
static void
-ossl_hmac_free(HMAC_CTX *ctx)
+ossl_hmac_free(void *ctx)
{
HMAC_CTX_cleanup(ctx);
ruby_xfree(ctx);
}
+static const rb_data_type_t ossl_hmac_type = {
+ "OpenSSL/HMAC",
+ {
+ 0, ossl_hmac_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
static VALUE
ossl_hmac_alloc(VALUE klass)
{