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

ruby-changes:36720

From: nobu <ko1@a...>
Date: Sat, 13 Dec 2014 06:59:08 +0900 (JST)
Subject: [ruby-changes:36720] nobu:r48800 (trunk): ossl_ssl.c: typed data

nobu	2014-12-13 06:58:31 +0900 (Sat, 13 Dec 2014)

  New Revision: 48800

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

  Log:
    ossl_ssl.c: typed data
    
    * ext/openssl/ossl_ssl.c (ossl_sslctx_type): use typed data.

  Modified files:
    trunk/ext/openssl/ossl_ssl.c
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 48799)
+++ ext/openssl/ossl_ssl.c	(revision 48800)
@@ -25,7 +25,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L25
 #endif
 
 #define GetSSLCTX(obj, ctx) do { \
-	Data_Get_Struct((obj), SSL_CTX, (ctx)); \
+	TypedData_Get_Struct((obj), SSL_CTX, &ossl_sslctx_type, (ctx));	\
 } while (0)
 
 VALUE mSSL;
@@ -154,13 +154,22 @@ int ossl_ssl_ex_client_cert_cb_idx; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L154
 int ossl_ssl_ex_tmp_dh_callback_idx;
 
 static void
-ossl_sslctx_free(SSL_CTX *ctx)
+ossl_sslctx_free(void *ptr)
 {
+    SSL_CTX *ctx = ptr;
     if(ctx && SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_store_p)== (void*)1)
 	ctx->cert_store = NULL;
     SSL_CTX_free(ctx);
 }
 
+static const rb_data_type_t ossl_sslctx_type = {
+    "OpenSSL/SSL/CTX",
+    {
+	0, ossl_sslctx_free,
+    },
+    0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
 static VALUE
 ossl_sslctx_s_alloc(VALUE klass)
 {
@@ -176,7 +185,7 @@ ossl_sslctx_s_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L185
         ossl_raise(eSSLError, "SSL_CTX_new");
     }
     SSL_CTX_set_mode(ctx, mode);
-    return Data_Wrap_Struct(klass, 0, ossl_sslctx_free, ctx);
+    return TypedData_Wrap_Struct(klass, &ossl_sslctx_type, ctx);
 }
 
 /*

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

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