[前][次][番号順一覧][スレッド一覧]

ruby-changes:36725

From: nobu <ko1@a...>
Date: Sat, 13 Dec 2014 08:19:27 +0900 (JST)
Subject: [ruby-changes:36725] nobu:r48806 (trunk): ossl_pkey.c: typed data

nobu	2014-12-13 08:19:07 +0900 (Sat, 13 Dec 2014)

  New Revision: 48806

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48806

  Log:
    ossl_pkey.c: typed data
    
    * ext/openssl/ossl_pkey.c (ossl_evp_pkey_type): use typed data.

  Modified files:
    trunk/ext/openssl/ossl_pkey.c
    trunk/ext/openssl/ossl_pkey.h
Index: ext/openssl/ossl_pkey.c
===================================================================
--- ext/openssl/ossl_pkey.c	(revision 48805)
+++ ext/openssl/ossl_pkey.c	(revision 48806)
@@ -69,9 +69,23 @@ ossl_generate_cb_stop(void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.c#L69
 }
 #endif
 
+static void
+ossl_evp_pkey_free(void *ptr)
+{
+    EVP_PKEY_free(ptr);
+}
+
 /*
  * Public
  */
+const rb_data_type_t ossl_evp_pkey_type = {
+    "OpenSSL/EVP_PKEY",
+    {
+	0, ossl_evp_pkey_free,
+    },
+    0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
 VALUE
 ossl_pkey_new(EVP_PKEY *pkey)
 {
Index: ext/openssl/ossl_pkey.h
===================================================================
--- ext/openssl/ossl_pkey.h	(revision 48805)
+++ ext/openssl/ossl_pkey.h	(revision 48806)
@@ -15,6 +15,7 @@ extern VALUE mPKey; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.h#L15
 extern VALUE cPKey;
 extern VALUE ePKeyError;
 extern ID id_private_q;
+extern const rb_data_type_t ossl_evp_pkey_type;
 
 #define OSSL_PKEY_SET_PRIVATE(obj) rb_iv_set((obj), "private", Qtrue)
 #define OSSL_PKEY_SET_PUBLIC(obj)  rb_iv_set((obj), "private", Qfalse)
@@ -24,11 +25,11 @@ extern ID id_private_q; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.h#L25
     if (!(pkey)) { \
 	rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
     } \
-    (obj) = Data_Wrap_Struct((klass), 0, EVP_PKEY_free, (pkey)); \
+    (obj) = TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, (pkey)); \
     OSSL_PKEY_SET_PUBLIC(obj); \
 } while (0)
 #define GetPKey(obj, pkey) do {\
-    Data_Get_Struct((obj), EVP_PKEY, (pkey));\
+    TypedData_Get_Struct((obj), EVP_PKEY, &ossl_evp_pkey_type, (pkey)); \
     if (!(pkey)) { \
 	rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
     } \

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]