~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_plugin.cc

  • Committer: Monty Taylor
  • Date: 2009-08-01 01:53:43 UTC
  • mto: (1106.1.4 memory-fix)
  • mto: This revision was merged to the branch mainline in revision 1107.
  • Revision ID: mordred@inaugust.com-20090801015343-zon3inx2npp8luch
Fixed the plugin string valgrind leak.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
{
52
52
  DRIZZLED_BUILTIN_LIST,(plugin::Manifest *)NULL
53
53
};
 
54
class sys_var_pluginvar;
 
55
static vector<sys_var_pluginvar *> plugin_sysvar_vec;
54
56
 
55
57
char *opt_plugin_load= NULL;
56
58
const char *opt_plugin_load_default= QUOTE_ARG(DRIZZLED_PLUGIN_LIST);
126
128
  plugin::Handle *plugin;
127
129
  struct st_mysql_sys_var *plugin_var;
128
130
 
129
 
  static void *operator new(size_t size, MEM_ROOT *mem_root)
130
 
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
131
 
  static void operator delete(void *, size_t)
132
 
  { TRASH(ptr_arg, size); }
133
 
 
134
 
  sys_var_pluginvar(const char *name_arg,
 
131
  sys_var_pluginvar(const std::string name_arg,
135
132
                    struct st_mysql_sys_var *plugin_var_arg)
136
133
    :sys_var(name_arg), plugin_var(plugin_var_arg) {}
137
134
  sys_var_pluginvar *cast_pluginvar() { return this; }
514
511
    plugin= *dynamic_element(&plugin_array, idx, drizzled::plugin::Handle **);
515
512
    plugin_del(plugin);
516
513
  }
 
514
  drizzle_del_plugin_sysvar();
517
515
}
518
516
 
519
517
static bool plugin_initialize(drizzled::plugin::Handle *plugin)
2105
2103
  return(opts);
2106
2104
}
2107
2105
 
 
2106
void drizzle_add_plugin_sysvar(sys_var_pluginvar *var)
 
2107
{
 
2108
  plugin_sysvar_vec.push_back(var);
 
2109
}
 
2110
 
 
2111
void drizzle_del_plugin_sysvar()
 
2112
{
 
2113
  vector<sys_var_pluginvar *>::iterator iter= plugin_sysvar_vec.begin();
 
2114
  while(iter != plugin_sysvar_vec.end())
 
2115
  {
 
2116
    delete *iter;
 
2117
    ++iter;
 
2118
  }
 
2119
  plugin_sysvar_vec.clear();
 
2120
}
2108
2121
 
2109
2122
/*
2110
2123
  SYNOPSIS
2124
2137
{
2125
2138
  struct sys_var_chain chain= { NULL, NULL };
2126
2139
  bool can_disable;
2127
 
  MEM_ROOT *mem_root= alloc_root_inited(&tmp->mem_root) ?
2128
 
                      &tmp->mem_root : &plugin_mem_root;
2129
2140
  st_mysql_sys_var **opt;
2130
2141
  my_option *opts= NULL;
2131
 
  char *p, *varname;
2132
2142
  int error;
2133
2143
  st_mysql_sys_var *o;
2134
2144
  struct st_bookmark *var;
2180
2190
        continue;
2181
2191
 
2182
2192
      if ((var= find_bookmark(tmp->getName().c_str(), o->name, o->flags)))
2183
 
        v= new (mem_root) sys_var_pluginvar(var->key + 1, o);
 
2193
        v= new sys_var_pluginvar(var->key + 1, o);
2184
2194
      else
2185
2195
      {
2186
2196
        len= tmp->getName().length() + strlen(o->name) + 2;
2187
 
        varname= (char*) alloc_root(mem_root, len);
2188
 
        sprintf(varname,"%s-%s",tmp->getName().c_str(),o->name);
2189
 
        my_casedn_str(&my_charset_utf8_general_ci, varname);
2190
 
 
2191
 
        for (p= varname; *p; p++)
 
2197
        string vname(tmp->getName());
 
2198
        vname.push_back('-');
 
2199
        vname.append(o->name);
 
2200
        transform(vname.begin(), vname.end(), vname.begin(), ::tolower);
 
2201
        string::iterator p= vname.begin();      
 
2202
        while  (p != vname.end())
 
2203
        {
2192
2204
          if (*p == '-')
2193
2205
            *p= '_';
 
2206
          ++p;
 
2207
        }
2194
2208
 
2195
 
        v= new (mem_root) sys_var_pluginvar(varname, o);
 
2209
        v= new sys_var_pluginvar(vname, o);
2196
2210
      }
2197
2211
      assert(v); /* check that an object was actually constructed */
2198
2212
 
 
2213
      drizzle_add_plugin_sysvar(static_cast<sys_var_pluginvar *>(v));
2199
2214
      /*
2200
2215
        Add to the chain of variables.
2201
2216
        Done like this for easier debugging so that the