mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-21 03:05:26 -04:00
Do not leak OpenedHandles.
Reviewed by Vedant Kumar (D30178) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295737 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
//
|
||||
// This file implements the operating system DynamicLibrary concept.
|
||||
//
|
||||
// FIXME: This file leaks ExplicitSymbols and OpenedHandles!
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
@@ -51,7 +49,7 @@ using namespace llvm::sys;
|
||||
//=== independent code.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static DenseSet<void *> *OpenedHandles = nullptr;
|
||||
static llvm::ManagedStatic<DenseSet<void *> > OpenedHandles;
|
||||
|
||||
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||
std::string *errMsg) {
|
||||
@@ -70,9 +68,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||
handle = RTLD_DEFAULT;
|
||||
#endif
|
||||
|
||||
if (!OpenedHandles)
|
||||
OpenedHandles = new DenseSet<void *>();
|
||||
|
||||
// If we've already loaded this library, dlclose() the handle in order to
|
||||
// keep the internal refcount at +1.
|
||||
if (!OpenedHandles->insert(handle).second)
|
||||
@@ -121,7 +116,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
|
||||
|
||||
#if defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)
|
||||
// Now search the libraries.
|
||||
if (OpenedHandles) {
|
||||
if (OpenedHandles.isConstructed()) {
|
||||
for (DenseSet<void *>::iterator I = OpenedHandles->begin(),
|
||||
E = OpenedHandles->end(); I != E; ++I) {
|
||||
//lt_ptr ptr = lt_dlsym(*I, symbolName);
|
||||
|
||||
Reference in New Issue
Block a user