ruby-changes:36711
From: nobu <ko1@a...>
Date: Sat, 13 Dec 2014 06:58:00 +0900 (JST)
Subject: [ruby-changes:36711] nobu:r48792 (trunk): ossl_engine.c: typed data
nobu 2014-12-13 06:57:49 +0900 (Sat, 13 Dec 2014) New Revision: 48792 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48792 Log: ossl_engine.c: typed data * ext/openssl/ossl_engine.c (ossl_engine_type): use typed data. Modified files: trunk/ext/openssl/ossl_engine.c Index: ext/openssl/ossl_engine.c =================================================================== --- ext/openssl/ossl_engine.c (revision 48791) +++ ext/openssl/ossl_engine.c (revision 48792) @@ -16,10 +16,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_engine.c#L16 if (!(engine)) { \ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \ } \ - (obj) = Data_Wrap_Struct((klass), 0, ENGINE_free, (engine)); \ + (obj) = TypedData_Wrap_Struct((klass), &ossl_engine_type, (engine)); \ } while(0) #define GetEngine(obj, engine) do { \ - Data_Get_Struct((obj), ENGINE, (engine)); \ + TypedData_Get_Struct((obj), ENGINE, &ossl_engine_type, (engine)); \ if (!(engine)) { \ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \ } \ @@ -57,6 +57,20 @@ do{\ https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_engine.c#L57 }\ }while(0) +static void +ossl_engine_free(void *engine) +{ + ENGINE_free(engine); +} + +static const rb_data_type_t ossl_engine_type = { + "OpenSSL/Engine", + { + 0, ossl_engine_free, + }, + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, +}; + /* Document-method: OpenSSL::Engine.load * * call-seq: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/