From 12c022c8aa5ab4a2aead09af918a06e84777a730 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Wed, 4 Aug 2010 19:32:14 -0700 Subject: [PATCH] move most previously global symbols to static to prevent conflicts (thanks for catching this Eric) --- ext/mysql2/client.c | 18 +++++++++++++++--- ext/mysql2/mysql2_ext.c | 19 +------------------ ext/mysql2/result.c | 22 ++++++++++++++++------ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index abda82e..3a06ed1 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -2,9 +2,10 @@ #include VALUE cMysql2Client; -extern VALUE mMysql2, cMysql2Error, intern_encoding_from_charset; -extern ID sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, sym_array; -extern ID intern_merge; +extern VALUE mMysql2, cMysql2Error; +static VALUE intern_encoding_from_charset; +static ID sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, sym_array; +static ID intern_merge; #define REQUIRE_OPEN_DB(_ctxt) \ if(!_ctxt->net.vio) { \ @@ -529,4 +530,15 @@ void init_mysql2_client() { rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5); rb_define_private_method(cMysql2Client, "init_connection", init_connection, 0); rb_define_private_method(cMysql2Client, "connect", rb_connect, 6); + + intern_encoding_from_charset = rb_intern("encoding_from_charset"); + + sym_id = ID2SYM(rb_intern("id")); + sym_version = ID2SYM(rb_intern("version")); + sym_async = ID2SYM(rb_intern("async")); + sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); + sym_as = ID2SYM(rb_intern("as")); + sym_array = ID2SYM(rb_intern("array")); + + intern_merge = rb_intern("merge"); } \ No newline at end of file diff --git a/ext/mysql2/mysql2_ext.c b/ext/mysql2/mysql2_ext.c index b027f45..dcb72f3 100644 --- a/ext/mysql2/mysql2_ext.c +++ b/ext/mysql2/mysql2_ext.c @@ -1,29 +1,12 @@ #include -VALUE mMysql2, cMysql2Error, intern_encoding_from_charset; -ID sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, - sym_array, sym_timezone, sym_utc, sym_local; -ID intern_merge; +VALUE mMysql2, cMysql2Error; /* Ruby Extension initializer */ void Init_mysql2() { mMysql2 = rb_define_module("Mysql2"); cMysql2Error = rb_const_get(mMysql2, rb_intern("Error")); - intern_merge = rb_intern("merge"); - - sym_timezone = ID2SYM(rb_intern("timezone")); - sym_utc = ID2SYM(rb_intern("utc")); - sym_local = ID2SYM(rb_intern("local")); - sym_array = ID2SYM(rb_intern("array")); - sym_as = ID2SYM(rb_intern("as")); - sym_id = ID2SYM(rb_intern("id")); - sym_version = ID2SYM(rb_intern("version")); - sym_async = ID2SYM(rb_intern("async")); - sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); - - intern_encoding_from_charset = rb_intern("encoding_from_charset"); - init_mysql2_client(); init_mysql2_result(); } diff --git a/ext/mysql2/result.c b/ext/mysql2/result.c index 0801030..b0880c6 100644 --- a/ext/mysql2/result.c +++ b/ext/mysql2/result.c @@ -4,13 +4,13 @@ rb_encoding *binaryEncoding; #endif -ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code; - VALUE cMysql2Result; VALUE cBigDecimal, cDate, cDateTime; -extern VALUE mMysql2, cMysql2Client, cMysql2Error, intern_encoding_from_charset; -extern ID sym_symbolize_keys, sym_as, sym_array, sym_timezone, sym_local, sym_utc; -extern ID intern_merge; +extern VALUE mMysql2, cMysql2Client, cMysql2Error; +static VALUE intern_encoding_from_charset; +static ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code; +static ID sym_symbolize_keys, sym_as, sym_array, sym_timezone, sym_local, sym_utc; +static ID intern_merge; static void rb_mysql_result_mark(void * wrapper) { mysql2_result_wrapper * w = wrapper; @@ -367,10 +367,20 @@ void init_mysql2_result() { rb_define_method(cMysql2Result, "each", rb_mysql_result_each, -1); rb_define_method(cMysql2Result, "fields", rb_mysql_result_fetch_fields, 0); + intern_encoding_from_charset = rb_intern("encoding_from_charset"); + intern_encoding_from_charset_code = rb_intern("encoding_from_charset_code"); + intern_new = rb_intern("new"); intern_utc = rb_intern("utc"); intern_local = rb_intern("local"); - intern_encoding_from_charset_code = rb_intern("encoding_from_charset_code"); + intern_merge = rb_intern("merge"); + + sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys")); + sym_as = ID2SYM(rb_intern("as")); + sym_array = ID2SYM(rb_intern("array")); + sym_timezone = ID2SYM(rb_intern("timezone")); + sym_local = ID2SYM(rb_intern("local")); + sym_utc = ID2SYM(rb_intern("utc")); #ifdef HAVE_RUBY_ENCODING_H binaryEncoding = rb_enc_find("binary");