[llvm-commits] CVS: llvm/lib/Support/PluginLoader.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Thu Jan 26 11:39:22 PST 2006



Changes in directory llvm/lib/Support:

PluginLoader.cpp updated: 1.16 -> 1.17
---
Log message:

dynamically allocate plugin space as needed

---
Diffs of the changes:  (+12 -5)

 PluginLoader.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)


Index: llvm/lib/Support/PluginLoader.cpp
diff -u llvm/lib/Support/PluginLoader.cpp:1.16 llvm/lib/Support/PluginLoader.cpp:1.17
--- llvm/lib/Support/PluginLoader.cpp:1.16	Thu Jan 26 12:36:43 2006
+++ llvm/lib/Support/PluginLoader.cpp	Thu Jan 26 13:38:58 2006
@@ -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 @@
 
 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];
 }






More information about the llvm-commits mailing list