@@ -1397,8 +1397,6 @@ void
13971397Init_ossl_asn1 (void )
13981398{
13991399#undef rb_intern
1400- VALUE ary ;
1401- int i ;
14021400
14031401 sym_UNIVERSAL = ID2SYM (rb_intern_const ("UNIVERSAL" ));
14041402 sym_CONTEXT_SPECIFIC = ID2SYM (rb_intern_const ("CONTEXT_SPECIFIC" ));
@@ -1548,17 +1546,20 @@ Init_ossl_asn1(void)
15481546 rb_define_module_function (mASN1 , "traverse" , ossl_asn1_traverse , 1 );
15491547 rb_define_module_function (mASN1 , "decode" , ossl_asn1_decode , 1 );
15501548 rb_define_module_function (mASN1 , "decode_all" , ossl_asn1_decode_all , 1 );
1551- ary = rb_ary_new ();
15521549
1550+ VALUE ary = rb_ary_new_capa (ossl_asn1_info_size );
1551+ for (int i = 0 ; i < ossl_asn1_info_size ; i ++ ) {
1552+ const char * name = ossl_asn1_info [i ].name ;
1553+ if (name [0 ] == '[' )
1554+ continue ;
1555+ rb_define_const (mASN1 , name , INT2NUM (i ));
1556+ rb_ary_store (ary , i , rb_obj_freeze (rb_str_new_cstr (name )));
1557+ }
1558+ rb_obj_freeze (ary );
15531559 /*
15541560 * Array storing tag names at the tag's index.
15551561 */
15561562 rb_define_const (mASN1 , "UNIVERSAL_TAG_NAME" , ary );
1557- for (i = 0 ; i < ossl_asn1_info_size ; i ++ ){
1558- if (ossl_asn1_info [i ].name [0 ] == '[' ) continue ;
1559- rb_define_const (mASN1 , ossl_asn1_info [i ].name , INT2NUM (i ));
1560- rb_ary_store (ary , i , rb_str_new2 (ossl_asn1_info [i ].name ));
1561- }
15621563
15631564 /* Document-class: OpenSSL::ASN1::ASN1Data
15641565 *
@@ -1880,6 +1881,7 @@ do{\
18801881 rb_hash_aset (class_tag_map , cASN1GeneralString , INT2NUM (V_ASN1_GENERALSTRING ));
18811882 rb_hash_aset (class_tag_map , cASN1UniversalString , INT2NUM (V_ASN1_UNIVERSALSTRING ));
18821883 rb_hash_aset (class_tag_map , cASN1BMPString , INT2NUM (V_ASN1_BMPSTRING ));
1884+ rb_obj_freeze (class_tag_map );
18831885
18841886 id_each = rb_intern_const ("each" );
18851887}
0 commit comments