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

ruby-changes:36719

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

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

  New Revision: 48801

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

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

  Modified files:
    trunk/ext/openssl/ossl_ssl.c
    trunk/ext/openssl/ossl_ssl.h
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 48800)
+++ ext/openssl/ossl_ssl.c	(revision 48801)
@@ -1133,15 +1133,23 @@ ossl_ssl_shutdown(SSL *ssl) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1133
 }
 
 static void
-ossl_ssl_free(SSL *ssl)
+ossl_ssl_free(void *ssl)
 {
     SSL_free(ssl);
 }
 
+const rb_data_type_t ossl_ssl_type = {
+    "OpenSSL/SSL",
+    {
+	0, ossl_ssl_free,
+    },
+    0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
 static VALUE
 ossl_ssl_s_alloc(VALUE klass)
 {
-    return Data_Wrap_Struct(klass, 0, ossl_ssl_free, NULL);
+    return TypedData_Wrap_Struct(klass, &ossl_ssl_type, NULL);
 }
 
 /*
Index: ext/openssl/ossl_ssl.h
===================================================================
--- ext/openssl/ossl_ssl.h	(revision 48800)
+++ ext/openssl/ossl_ssl.h	(revision 48801)
@@ -12,7 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.h#L12
 #define _OSSL_SSL_H_
 
 #define GetSSL(obj, ssl) do { \
-	Data_Get_Struct((obj), SSL, (ssl)); \
+	TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
 } while (0)
 
 #define GetSSLSession(obj, sess) do { \
@@ -27,6 +27,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.h#L27
 	GetSSLSession((obj), (sess)); \
 } while (0)
 
+extern const rb_data_type_t ossl_ssl_type;
 extern const rb_data_type_t ossl_ssl_session_type;
 extern VALUE mSSL;
 extern VALUE eSSLError;

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

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