aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugin.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-09-15 23:09:44 +0200
committercbdev <cb@cbcdn.com>2019-09-15 23:09:44 +0200
commit1c8d7c570678c2f4f3bf61529489336f9d085f8d (patch)
treec96fae6d14629160ab2f739ea8bd4741b77db6bd /plugin.c
parent9997c446677e490a0d376701f838e804c3b28644 (diff)
downloadmidimonster-1c8d7c570678c2f4f3bf61529489336f9d085f8d.tar.gz
midimonster-1c8d7c570678c2f4f3bf61529489336f9d085f8d.tar.bz2
midimonster-1c8d7c570678c2f4f3bf61529489336f9d085f8d.zip
Fix minor MIDI issues
Diffstat (limited to 'plugin.c')
-rw-r--r--plugin.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugin.c b/plugin.c
index a452559..dd99041 100644
--- a/plugin.c
+++ b/plugin.c
@@ -24,7 +24,6 @@ static int plugin_attach(char* path, char* file){
plugin_init init = NULL;
void* handle = NULL;
char* lib = NULL;
- char* error = NULL;
lib = calloc(strlen(path) + strlen(file) + 1, sizeof(char));
if(!lib){
@@ -36,16 +35,15 @@ static int plugin_attach(char* path, char* file){
handle = dlopen(lib, RTLD_NOW);
if(!handle){
#ifdef _WIN32
+ char* error = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error, 0, NULL);
- #else
- error = dlerror();
- #endif
fprintf(stderr, "Failed to load plugin %s: %s\n", lib, error);
- free(lib);
- #ifdef _WIN32
LocalFree(error);
+ #else
+ fprintf(stderr, "Failed to load plugin %s: %s\n", lib, dlerror());
#endif
+ free(lib);
return 0;
}
@@ -156,10 +154,22 @@ load_done:
int plugins_close(){
size_t u;
+
for(u = 0; u < plugins; u++){
+#ifdef _WIN32
+ char* error = NULL;
+ //FreeLibrary returns the inverse of dlclose
+ if(!FreeLibrary(plugin_handle[u])){
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error, 0, NULL);
+ fprintf(stderr, "Failed to unload plugin: %s\n", error);
+ LocalFree(error);
+ }
+#else
if(dlclose(plugin_handle[u])){
fprintf(stderr, "Failed to unload plugin: %s\n", dlerror());
}
+#endif
}
free(plugin_handle);