[PATCH] D30178: Do not leak OpenedHandles
Vassil Vassilev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 20 12:41:49 PST 2017
v.g.vassilev created this revision.
Repository:
rL LLVM
https://reviews.llvm.org/D30178
Files:
lib/Support/DynamicLibrary.cpp
lib/Support/Windows/DynamicLibrary.inc
Index: lib/Support/Windows/DynamicLibrary.inc
===================================================================
--- lib/Support/Windows/DynamicLibrary.inc
+++ lib/Support/Windows/DynamicLibrary.inc
@@ -9,6 +9,8 @@
//
// This file provides the Win32 specific implementation of DynamicLibrary.
//
+// FIXME: This file leaks OpenedHandles!
+//
//===----------------------------------------------------------------------===//
#include "WindowsSupport.h"
Index: lib/Support/DynamicLibrary.cpp
===================================================================
--- lib/Support/DynamicLibrary.cpp
+++ lib/Support/DynamicLibrary.cpp
@@ -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 @@
//=== independent code.
//===----------------------------------------------------------------------===//
-static DenseSet<void *> *OpenedHandles = nullptr;
+static llvm::ManagedStatic<DenseSet<void *> > OpenedHandles;
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
std::string *errMsg) {
@@ -121,7 +119,7 @@
#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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30178.89143.patch
Type: text/x-patch
Size: 1655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170220/22fae4ac/attachment.bin>
More information about the llvm-commits
mailing list