mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 22:20:37 +00:00
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:
parent
1feeeecf4c
commit
9d90144099
@ -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];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user