~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_plugin.cc

  • Committer: Monty Taylor
  • Date: 2009-07-16 17:37:03 UTC
  • mto: (1093.1.18 captain)
  • mto: This revision was merged to the branch mainline in revision 1098.
  • Revision ID: mordred@inaugust.com-20090716173703-kwbn8wd2eml3yp8j
Removed a dynamic array.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2075
2075
}
2076
2076
 
2077
2077
 
2078
 
static my_option *construct_help_options(MEM_ROOT *mem_root,
2079
 
                                         Handle *p)
 
2078
static my_option *construct_help_options(MEM_ROOT *mem_root, Handle *p)
2080
2079
{
2081
2080
  st_mysql_sys_var **opt;
2082
2081
  my_option *opts;
2085
2084
 
2086
2085
  for (opt= p->getManifest().system_vars; opt && *opt; opt++, count+= 2) {};
2087
2086
 
2088
 
  if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count)))
 
2087
  opts= (my_option*)alloc_root(mem_root, (sizeof(my_option) * count));
 
2088
  if (opts == NULL)
2089
2089
    return NULL;
2090
2090
 
2091
2091
  memset(opts, 0, sizeof(my_option) * count);
2227
2227
  Help Verbose text with Plugin System Variables
2228
2228
****************************************************************************/
2229
2229
 
2230
 
static int option_cmp(my_option *a, my_option *b)
2231
 
{
2232
 
  return my_strcasecmp(&my_charset_utf8_general_ci, a->name, b->name);
2233
 
}
2234
 
 
2235
 
 
2236
 
void my_print_help_inc_plugins(my_option *main_options, uint32_t size)
2237
 
{
2238
 
  DYNAMIC_ARRAY all_options;
 
2230
class OptionCmp
 
2231
{
 
2232
public:
 
2233
  bool operator() (const my_option &a, const my_option &b)
 
2234
  {
 
2235
    return my_strcasecmp(&my_charset_utf8_general_ci, a.name, b.name);
 
2236
  }
 
2237
};
 
2238
 
 
2239
 
 
2240
void my_print_help_inc_plugins(my_option *main_options)
 
2241
{
 
2242
  vector<my_option> all_options;
2239
2243
  Handle *p;
2240
2244
  MEM_ROOT mem_root;
2241
 
  my_option *opt;
 
2245
  my_option *opt= NULL;
2242
2246
 
2243
2247
  init_alloc_root(&mem_root, 4096, 4096);
2244
 
  my_init_dynamic_array(&all_options, sizeof(my_option), size, size/4);
2245
2248
 
2246
2249
  if (initialized)
2247
2250
    for (uint32_t idx= 0; idx < plugin_array.elements; idx++)
2248
2251
    {
2249
2252
      p= *dynamic_element(&plugin_array, idx, Handle **);
2250
2253
 
2251
 
      if (!p->getManifest().system_vars ||
2252
 
          !(opt= construct_help_options(&mem_root, p)))
 
2254
      if (p->getManifest().system_vars == NULL)
 
2255
        continue;
 
2256
 
 
2257
      opt= construct_help_options(&mem_root, p);
 
2258
      if (opt == NULL)
2253
2259
        continue;
2254
2260
 
2255
2261
      /* Only options with a non-NULL comment are displayed in help text */
2256
2262
      for (;opt->id; opt++)
 
2263
      {
2257
2264
        if (opt->comment)
2258
 
          insert_dynamic(&all_options, (unsigned char*) opt);
 
2265
        {
 
2266
          all_options.push_back(*opt);
 
2267
          
 
2268
        }
 
2269
      }
2259
2270
    }
2260
2271
 
2261
2272
  for (;main_options->id; main_options++)
2262
 
    insert_dynamic(&all_options, (unsigned char*) main_options);
 
2273
  {
 
2274
    if (main_options->comment)
 
2275
    {
 
2276
      all_options.push_back(*main_options);
 
2277
    }
 
2278
  }
2263
2279
 
2264
 
  sort_dynamic(&all_options, (qsort_cmp) option_cmp);
 
2280
  /** 
 
2281
   * @TODO: Fix the my_option building so that it doens't break sort
 
2282
   *
 
2283
   * sort(all_options.begin(), all_options.end(), OptionCmp());
 
2284
   */
2265
2285
 
2266
2286
  /* main_options now points to the empty option terminator */
2267
 
  insert_dynamic(&all_options, (unsigned char*) main_options);
2268
 
 
2269
 
  my_print_help((my_option*) all_options.buffer);
2270
 
  my_print_variables((my_option*) all_options.buffer);
2271
 
 
2272
 
  delete_dynamic(&all_options);
 
2287
  all_options.push_back(*main_options);
 
2288
 
 
2289
  my_print_help(&*(all_options.begin()));
 
2290
  my_print_variables(&*(all_options.begin()));
 
2291
 
2273
2292
  free_root(&mem_root, MYF(0));
 
2293
 
2274
2294
}
2275
2295