dynamically allocate plugin space as needed

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25652 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Lenharth 2006-01-26 19:38:58 +00:00
parent 1feeeecf4c
commit 9d90144099

View File

@ -19,13 +19,17 @@
using namespace llvm;
std::vector<std::string> plugins;
static std::vector<std::string>* plugins;
void PluginLoader::operator=(const std::string &Filename) {
std::string ErrorMessage;
if (!plugins)
plugins = new std::vector<std::string>();
try {
sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str());
plugins.push_back(Filename);
plugins->push_back(Filename);
} catch (const std::string& errmsg) {
if (errmsg.empty()) {
ErrorMessage = "Unknown";
@ -40,11 +44,14 @@ void PluginLoader::operator=(const std::string &Filename) {
unsigned PluginLoader::getNumPlugins()
{
return plugins.size();
if(plugins)
return plugins->size();
else
return 0;
}
std::string& PluginLoader::getPlugin(unsigned num)
{
assert(num < plugins.size() && "Asking for an out of bounds plugin");
return plugins[num];
assert(plugins && num < plugins->size() && "Asking for an out of bounds plugin");
return (*plugins)[num];
}