diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-02-20 22:04:52 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-02-20 22:04:52 +0000 |
| commit | 6cd34b318fc46620ea85991dd1e03ea390960da3 (patch) | |
| tree | 0a20c064660b03e8d440a517daa76c8707b7f514 /Source/Core/Common/Src/DynamicLibrary.cpp | |
| parent | f992dae50ddbd7c20d63e6d48d5051fc1d6b392b (diff) | |
The Mega Change Of Doom - or, fixing Stop. Almost. At least it's better than before. However, the OpenGL plugin seems to lose textures a lot between game restarts :P I think the GL plugin needs to do a lot more cleanup.
This change also includes tons of minor code formatting cleanup. Yeah, should've separated it ... sorry :(
Kills the old CPUCompare support. I'll resurrect it if I need it again, right now it mostly clutters the code.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2321 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/DynamicLibrary.cpp')
| -rw-r--r-- | Source/Core/Common/Src/DynamicLibrary.cpp | 120 |
1 files changed, 59 insertions, 61 deletions
diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index dcec5fc9d3..f547d84ea1 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -15,10 +15,8 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -/* - All plugins from Core > Plugins are loaded and unloaded with this class when - Dolpin is started and stopped. -*/ +// All plugins from Core > Plugins are loaded and unloaded with this class when +// Dolphin is started and stopped. #include <string.h> // System #ifdef _WIN32 @@ -34,7 +32,6 @@ #include "DynamicLibrary.h" #include "ConsoleWindow.h" - DynamicLibrary::DynamicLibrary() { library = 0; @@ -42,33 +39,33 @@ DynamicLibrary::DynamicLibrary() std::string GetLastErrorAsString() { - #ifdef _WIN32 - LPVOID lpMsgBuf = 0; - DWORD error = GetLastError(); - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, NULL); - std::string s; - if (lpMsgBuf) - { - s = ((char *)lpMsgBuf); - LocalFree(lpMsgBuf); - } else { - s = StringFromFormat("(unknown error %08x)", error); - } - return s; - #else - static std::string errstr; - char *tmp = dlerror(); - if (tmp) - errstr = tmp; - - return errstr; - #endif +#ifdef _WIN32 + LPVOID lpMsgBuf = 0; + DWORD error = GetLastError(); + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + error, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, NULL); + std::string s; + if (lpMsgBuf) + { + s = ((char *)lpMsgBuf); + LocalFree(lpMsgBuf); + } else { + s = StringFromFormat("(unknown error %08x)", error); + } + return s; +#else + static std::string errstr; + char *tmp = dlerror(); + if (tmp) + errstr = tmp; + + return errstr; +#endif } /* Function: Loading means loading the dll with LoadLibrary() to get an @@ -81,15 +78,16 @@ std::string GetLastErrorAsString() Called from: The Dolphin Core */ int DynamicLibrary::Load(const char* filename) { - if (!filename || strlen(filename) == 0) { - LOG(MASTER_LOG, "Missing filename of dynamic library to load"); - PanicAlert("Missing filename of dynamic library to load"); - return 0; + if (!filename || strlen(filename) == 0) + { + LOG(MASTER_LOG, "Missing filename of dynamic library to load"); + PanicAlert("Missing filename of dynamic library to load"); + return 0; } - LOG(MASTER_LOG, "Trying to load library %s", filename); - if (IsLoaded()) { - LOG(MASTER_LOG, "Trying to load already loaded library %s", filename); - return 2; + if (IsLoaded()) + { + LOG(MASTER_LOG, "Trying to load already loaded library %s", filename); + return 2; } Console::Print("LoadLibrary: %s", filename); @@ -99,10 +97,11 @@ int DynamicLibrary::Load(const char* filename) library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); #endif Console::Print(" %p\n", library); - if (!library) { - LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); - PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); - return 0; + if (!library) + { + LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); + PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); + return 0; } library_file = filename; @@ -111,28 +110,29 @@ int DynamicLibrary::Load(const char* filename) int DynamicLibrary::Unload() { - int retval; - if (!IsLoaded()) { - PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str()); - return 0; - } + int retval; + if (!IsLoaded()) + { + PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str()); + return 0; + } - Console::Print("FreeLibrary: %s %p\n", library_file.c_str(), library); + Console::Print("FreeLibrary: %s %p\n", library_file.c_str(), library); #ifdef _WIN32 - retval = FreeLibrary(library); + retval = FreeLibrary(library); #else - retval = dlclose(library)?0:1; + retval = dlclose(library)?0:1; #endif - if (! retval) { - PanicAlert("Error unloading DLL %s: %s", library_file.c_str(), - GetLastErrorAsString().c_str()); - } - library = 0; - return retval; + if (!retval) + { + PanicAlert("Error unloading DLL %s: %s", library_file.c_str(), + GetLastErrorAsString().c_str()); + } + library = 0; + return retval; } - void* DynamicLibrary::Get(const char* funcname) const { void* retval; @@ -156,5 +156,3 @@ void* DynamicLibrary::Get(const char* funcname) const return retval; } - - |
