[Groonga-mysql-commit] mroonga/mroonga [master] allocate default_parser memory in mrn_init() with my_malloc().

Back to archive index

null+****@clear***** null+****@clear*****
2011年 11月 1日 (火) 00:37:35 JST


Kouhei Sutou	2011-10-31 15:37:35 +0000 (Mon, 31 Oct 2011)

  New Revision: 334588480212f8e6840bd1e03910fa07376c7658

  Log:
    allocate default_parser memory in mrn_init() with my_malloc().

  Modified files:
    ha_mroonga.cc

  Modified: ha_mroonga.cc (+5 -4)
===================================================================
--- ha_mroonga.cc    2011-10-31 14:56:15 +0000 (0525209)
+++ ha_mroonga.cc    2011-10-31 15:37:35 +0000 (9fab20b)
@@ -109,7 +109,6 @@ FILE *mrn_logfile = NULL;
 static bool mrn_logfile_opened = false;
 grn_log_level mrn_log_level_default = GRN_LOG_DEFAULT_LEVEL;
 ulong mrn_log_level = (ulong) mrn_log_level_default;
-char mrn_default_parser_name[MRN_MAX_KEY_SIZE];
 char *mrn_default_parser;
 
 static void mrn_logger_func(int level, const char *time, const char *title,
@@ -228,13 +227,12 @@ static void mrn_default_parser_update(THD *thd, struct st_mysql_sys_var *var,
           "default parser changed from '%s' to '%s'",
           old_value, new_value);
   grn_ctx_fin(&ctx);
-  strcpy(mrn_default_parser_name, new_value);
-  mrn_default_parser = mrn_default_parser_name;
+  strncpy(mrn_default_parser, new_value, MRN_MAX_KEY_SIZE - 1);
   DBUG_VOID_RETURN;
 }
 
 static MYSQL_SYSVAR_STR(default_parser, mrn_default_parser,
-                        PLUGIN_VAR_RQCMDARG,
+                        PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
                         "default fulltext parser",
                         NULL,
                         mrn_default_parser_update,
@@ -1010,6 +1008,9 @@ static int mrn_init(void *p)
     goto error_allocated_open_tables_hash_init;
   }
 
+  mrn_default_parser = (char *)my_malloc(MRN_MAX_KEY_SIZE, MYF(MY_WME));
+  strncpy(mrn_default_parser, MRN_PARSER_DEFAULT, MRN_MAX_KEY_SIZE - 1);
+
   return 0;
 
 error_allocated_open_tables_hash_init:




Groonga-mysql-commit メーリングリストの案内
Back to archive index