summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit4558e4ae10dc9f2cc5f857e1c4f6fbfd054ff29d (patch)
tree9a41ed39ac1e5bfca3f1c91fc249435c89eef5c4 /llvm/lib/Support/PluginLoader.cpp
parente9025f1f3ba4447d5314895a28e36e414490763c (diff)
downloadbcm5719-llvm-4558e4ae10dc9f2cc5f857e1c4f6fbfd054ff29d.tar.gz
bcm5719-llvm-4558e4ae10dc9f2cc5f857e1c4f6fbfd054ff29d.zip
dynamically allocate plugin space as needed
llvm-svn: 25652
Diffstat (limited to 'llvm/lib/Support/PluginLoader.cpp')
-rw-r--r--llvm/lib/Support/PluginLoader.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Support/PluginLoader.cpp b/llvm/lib/Support/PluginLoader.cpp
index 77eb52852de..94cbec3a933 100644
--- a/llvm/lib/Support/PluginLoader.cpp
+++ b/llvm/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];
}
OpenPOWER on IntegriCloud