summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsvensson@pilot.mysql.com <>2006-12-22 12:14:37 +0100
committermsvensson@pilot.mysql.com <>2006-12-22 12:14:37 +0100
commit791a5cf75efc1255a158135c9830a6bf14d726d6 (patch)
treead5c8881e8aa5840159e48faaf3698f4b44a84b3
parenteb7500f44a964af5370c09d5eb68f1b84a32faba (diff)
parentabe43135b16fb0cbb2aa8e5fff05660bc11dbb7f (diff)
downloadmariadb-git-791a5cf75efc1255a158135c9830a6bf14d726d6.tar.gz
Merge pilot.mysql.com:/home/msvensson/mysql/my51-ndb-gca-my51-m
into pilot.mysql.com:/home/msvensson/mysql/mysql-5.1-new-ndb
-rw-r--r--sql/sql_plugin.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 8cd4c661fb8..9ff88b2054a 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -951,29 +951,30 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
state_mask= ~state_mask; // do it only once
rw_rdlock(&THR_LOCK_plugin);
+ total= type == MYSQL_ANY_PLUGIN ? plugin_array.elements
+ : plugin_hash[type].records;
+ /*
+ Do the alloca out here in case we do have a working alloca:
+ leaving the nested stack frame invalidates alloca allocation.
+ */
+ plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins));
if (type == MYSQL_ANY_PLUGIN)
{
- total=plugin_array.elements;
- plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins));
for (idx= 0; idx < total; idx++)
{
plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *);
- if (plugin->state & state_mask)
- continue;
- plugins[idx]= plugin;
+ plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
}
}
else
{
- HASH *hash= &plugin_hash[type];
- total=hash->records;
- plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins));
+ HASH *hash= plugin_hash + type;
for (idx= 0; idx < total; idx++)
{
plugin= (struct st_plugin_int *) hash_element(hash, idx);
if (plugin->state & state_mask)
continue;
- plugins[idx]= plugin;
+ plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
}
}
rw_unlock(&THR_LOCK_plugin);