aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/PluginLoader.cpp
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2006-01-26 19:38:58 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2006-01-26 19:38:58 +0000
commit9d9014409972956a9d644585a44aaab0e6ddba3a (patch)
tree668701916cd8ed06c3a7b05a56ee3bf20280844d /lib/Support/PluginLoader.cpp
parent1feeeecf4cb28e34c7577719087aa41ec6610b28 (diff)
dynamically allocate plugin space as needed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25652 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/PluginLoader.cpp')
-rw-r--r--lib/Support/PluginLoader.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp
index 77eb52852d..94cbec3a93 100644
--- a/lib/Support/PluginLoader.cpp
+++ b/lib/Support/PluginLoader.cpp
@@ -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];
}