aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_hmac.c
diff options
context:
space:
mode:
authorZachary Scott <e@zzak.io>2015-01-05 11:59:50 -0800
committerZachary Scott <e@zzak.io>2015-01-05 11:59:50 -0800
commit2953dfd4ad925a669110fed1993d6e83b24e420f (patch)
tree05e4d2a6750e0ce6dd408c2b8f2f5bf597cfe54a /ext/openssl/ossl_hmac.c
parent77269de78e376981342127d30dc0b953b9bcd781 (diff)
downloadruby-openssl-2953dfd4ad925a669110fed1993d6e83b24e420f.tar.gz
Sync with ruby trunk
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 516e3ed8..74fc962b 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)
{