summaryrefslogtreecommitdiff
path: root/mysys/my_getopt.c
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mysql.com>2007-04-26 21:26:04 +0200
committerunknown <serg@sergbook.mysql.com>2007-04-26 21:26:04 +0200
commit6cc76eb61cb190d5ec410ffe3bd2e064e7951e44 (patch)
tree3f0bb0440f009d5eb738bbdc119edada18c81f97 /mysys/my_getopt.c
parent04c015fbda381128d058619527908aac57dcae09 (diff)
downloadmariadb-git-6cc76eb61cb190d5ec410ffe3bd2e064e7951e44.tar.gz
fixed: memleak in --help, sigsegv on shutdown
Ingo's patch: WL#2936 - Falcon & MySQL plugin interface: server variables Added initialization for plugin string variables with their default values. Added deallocation of string values before a plugin and its variables is deleted. Added examples to plugin_example mysys/my_getopt.c: Ingo's patch: WL#2936 - Falcon & MySQL plugin interface: server variables Added initialization for string options. Since string variables do often have their default value assigned already, assign the default value only if the variable value is NULL. plugin/fulltext/plugin_example.c: Ingo's patch: WL#2936 - Falcon & MySQL plugin interface: server variables Added examples for thread variables, which have a SESSION and a GLOBAL value. sql/mysqld.cc: removed second fix_paths() in --help output (memory leak). removed invalid string defaul values (binlog_format) don't hide the error message in the help text sql/sql_plugin.cc: don't do plugin_dl_del for built-in plugins (sigsegv). Ingo's patch: WL#2936 - Falcon & MySQL plugin interface: server variables Clearing newly allocated variable value space. This is important for string variables. They are initialized to their default value only if their initial value is NULL. Setting default values for strings. Added a function to free global value space for string variables. Call the function before deleting a plugin and its variables.
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r--mysys/my_getopt.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index dd2663970ee..3c67c724a9a 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -813,6 +813,7 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp)
static void init_one_value(const struct my_option *option, gptr *variable,
longlong value)
{
+ DBUG_ENTER("init_one_value");
switch ((option->var_type & GET_TYPE_MASK)) {
case GET_BOOL:
*((my_bool*) variable)= (my_bool) value;
@@ -837,9 +838,29 @@ static void init_one_value(const struct my_option *option, gptr *variable,
case GET_SET:
*((ulonglong*) variable)= (ulonglong) value;
break;
+ case GET_STR:
+ /*
+ Do not clear variable value if it has no default value.
+ The default value may already be set.
+ */
+ if ((char*) value)
+ *((char**) variable)= (char*) value;
+ break;
+ case GET_STR_ALLOC:
+ /*
+ Do not clear variable value if it has no default value.
+ The default value may already be set.
+ */
+ if ((char*) value)
+ {
+ my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR));
+ *((char**) variable)= my_strdup((char*) value, MYF(MY_WME));
+ }
+ break;
default: /* dummy default to avoid compiler warnings */
break;
}
+ DBUG_VOID_RETURN;
}
@@ -858,9 +879,11 @@ static void init_one_value(const struct my_option *option, gptr *variable,
static void init_variables(const struct my_option *options)
{
+ DBUG_ENTER("init_variables");
for (; options->name; options++)
{
gptr *variable;
+ DBUG_PRINT("options", ("name: '%s'", options->name));
/*
We must set u_max_value first as for some variables
options->u_max_value == options->value and in this case we want to
@@ -874,6 +897,7 @@ static void init_variables(const struct my_option *options)
(variable= (*getopt_get_addr)("", 0, options)))
init_one_value(options, variable, options->def_value);
}
+ DBUG_VOID_RETURN;
}