Skip to content

Commit

Permalink
Multiplatform Runtime loaded library clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Oct 4, 2024
1 parent b067781 commit 236bccf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
#include <thread>
#include <vector>

#include <dlfcn.h>
#if defined(__unix__) || defined(__linux__)
# include <dlfcn.h>
#elif defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
# include <Windows.h>
#else
# error "Unsupported architecture for shared objects or dynamic libraries."
#endif

bool Runtime::testMode = false;
std::unordered_map<std::string, void*> Runtime::nativeLibraries;
Expand Down Expand Up @@ -51,7 +57,11 @@ bool Runtime::hasLoadedLibrary(std::string libName) {
void Runtime::cleanUp() {
for(const auto& [key, value] : Runtime::nativeLibraries)
if(value != nullptr)
#if defined(__unix__) || defined(__linux__)
dlclose(value);
#elif defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
FreeLibrary(value);
#endif

Runtime::nativeLibraries.clear();
}

0 comments on commit 236bccf

Please sign in to comment.