~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/loader.cc

  • Committer: mordred
  • Date: 2010-04-20 00:04:22 UTC
  • mfrom: (1491 bad-staging)
  • mto: This revision was merged to the branch mainline in revision 1498.
  • Revision ID: mordred@orisndriz09-20100420000422-if6mil1596804mrj
Merged up with build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
  write-lock on LOCK_system_variables_hash is required before modifying
85
85
  the following variables/structures
86
86
*/
87
 
static memory::Root plugin_mem_root;
 
87
static memory::Root plugin_mem_root(4096);
88
88
static uint32_t global_variables_dynamic_size= 0;
89
89
static HASH bookmark_hash;
90
90
 
375
375
  plugin::Manifest **builtins;
376
376
  plugin::Manifest *manifest;
377
377
  plugin::Module *module;
378
 
  memory::Root tmp_root;
 
378
  memory::Root tmp_root(4096);
379
379
 
380
380
  if (initialized)
381
381
    return false;
382
382
 
383
 
  init_alloc_root(&plugin_mem_root, 4096);
384
 
  init_alloc_root(&tmp_root, 4096);
385
 
 
386
383
  if (hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0,
387
384
                  get_bookmark_hash_key, NULL, HASH_UNIQUE))
388
385
  {
389
 
    free_root(&tmp_root, MYF(0));
 
386
    tmp_root.free_root(MYF(0));
390
387
    return true;
391
388
  }
392
389
 
405
402
      if (module == NULL)
406
403
        return true;
407
404
 
408
 
      free_root(&tmp_root, MYF(memory::MARK_BLOCKS_FREE));
 
405
      tmp_root.free_root(MYF(memory::MARK_BLOCKS_FREE));
409
406
      if (test_plugin_options(&tmp_root, module, argc, argv))
410
407
        continue;
411
408
 
417
414
      {
418
415
        if (plugin_initialize(registry, module))
419
416
        {
420
 
          free_root(&tmp_root, MYF(0));
 
417
          tmp_root.free_root(MYF(0));
421
418
          return true;
422
419
        }
423
420
      }
455
452
                                plugin_list_set);
456
453
  if (load_failed)
457
454
  {
458
 
    free_root(&tmp_root, MYF(0));
 
455
    tmp_root.free_root(MYF(0));
459
456
    return true;
460
457
  }
461
458
 
462
459
  if (skip_init)
463
460
  {
464
 
    free_root(&tmp_root, MYF(0));
 
461
    tmp_root.free_root(MYF(0));
465
462
    return false;
466
463
  }
467
464
 
485
482
  }
486
483
 
487
484
 
488
 
  free_root(&tmp_root, MYF(0));
 
485
  tmp_root.free_root(MYF(0));
489
486
 
490
487
  return false;
491
488
}
544
541
      return true;
545
542
    }
546
543
 
547
 
    free_root(tmp_root, MYF(memory::MARK_BLOCKS_FREE));
 
544
    tmp_root->free_root(MYF(memory::MARK_BLOCKS_FREE));
548
545
    if (plugin_add(registry, tmp_root, library, argc, argv))
549
546
    {
550
547
      registry.removeLibrary(plugin_name);
579
576
  /* Dispose of the memory */
580
577
 
581
578
  hash_free(&bookmark_hash);
582
 
  free_root(&plugin_mem_root, MYF(0));
 
579
  plugin_mem_root.free_root(MYF(0));
583
580
 
584
581
  global_variables_dynamic_size= 0;
585
582
}
899
896
  {
900
897
    const string varname(make_bookmark_name(plugin, name, flags));
901
898
 
902
 
    result= static_cast<st_bookmark*>(alloc_root(&plugin_mem_root,
903
 
                                      sizeof(struct st_bookmark) + varname.size() + 1));
 
899
    result= static_cast<st_bookmark*>(plugin_mem_root.alloc_root(sizeof(struct st_bookmark) + varname.size() + 1));
904
900
    memset(result->key, 0, varname.size()+1);
905
901
    memcpy(result->key, varname.c_str(), varname.size());
906
902
    result->name_len= varname.size() - 2;
1572
1568
    if (!(opt->flags & PLUGIN_VAR_SessionLOCAL))
1573
1569
    {
1574
1570
      optnamelen= strlen(opt->name);
1575
 
      optname= (char*) alloc_root(mem_root, namelen + optnamelen + 2);
 
1571
      optname= (char*) mem_root->alloc_root(namelen + optnamelen + 2);
1576
1572
      sprintf(optname, "%s-%s", name.c_str(), opt->name);
1577
1573
      optnamelen= namelen + optnamelen + 1;
1578
1574
    }
1591
1587
      if (opt->flags & PLUGIN_VAR_NOCMDOPT)
1592
1588
        continue;
1593
1589
 
1594
 
      optname= (char*) memdup_root(mem_root, v->key + 1,
1595
 
                                   (optnamelen= v->name_len) + 1);
 
1590
      optname= (char*) mem_root->memdup_root(v->key + 1, (optnamelen= v->name_len) + 1);
1596
1591
    }
1597
1592
 
1598
1593
    /* convert '_' to '-' */
1628
1623
 
1629
1624
  for (opt= p->getManifest().system_vars; opt && *opt; opt++, count++) {};
1630
1625
 
1631
 
  opts= (option*)alloc_root(mem_root, (sizeof(option) * count));
 
1626
  opts= (option*)mem_root->alloc_root((sizeof(option) * count));
1632
1627
  if (opts == NULL)
1633
1628
    return NULL;
1634
1629
 
1686
1681
 
1687
1682
  if (count > EXTRA_OPTIONS || (*argc > 1))
1688
1683
  {
1689
 
    if (!(opts= (option*) alloc_root(tmp_root, sizeof(option) * count)))
 
1684
    if (!(opts= (option*) tmp_root->alloc_root(sizeof(option) * count)))
1690
1685
    {
1691
1686
      errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory for plugin '%s'."), tmp->getName().c_str());
1692
1687
      return(-1);
1788
1783
  plugin::Registry &registry= plugin::Registry::singleton();
1789
1784
  vector<option> all_options;
1790
1785
  plugin::Module *p;
1791
 
  memory::Root mem_root;
 
1786
  memory::Root mem_root(4096);
1792
1787
  option *opt= NULL;
1793
1788
 
1794
 
  init_alloc_root(&mem_root, 4096);
1795
 
 
1796
1789
  if (initialized)
1797
1790
  {
1798
1791
    std::map<std::string, plugin::Module *>::const_iterator modules=
1842
1835
  my_print_help(&*(all_options.begin()));
1843
1836
  my_print_variables(&*(all_options.begin()));
1844
1837
 
1845
 
  free_root(&mem_root, MYF(0));
1846
 
 
 
1838
  mem_root.free_root(MYF(0));
1847
1839
}
1848
1840
 
1849
1841
} /* namespace drizzled */