[PATCH] D83372: Fix for memory leak reported by Valgrind
Maksym Wezdecki via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 04:38:44 PDT 2020
mwezdeck updated this revision to Diff 290240.
mwezdeck added a comment.
I'm uploading new revision, according to suggestions above.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83372/new/
https://reviews.llvm.org/D83372
Files:
llvm/lib/Support/ManagedStatic.cpp
Index: llvm/lib/Support/ManagedStatic.cpp
===================================================================
--- llvm/lib/Support/ManagedStatic.cpp
+++ llvm/lib/Support/ManagedStatic.cpp
@@ -18,16 +18,10 @@
using namespace llvm;
static const ManagedStaticBase *StaticList = nullptr;
-static std::recursive_mutex *ManagedStaticMutex = nullptr;
-static llvm::once_flag mutex_init_flag;
-
-static void initializeMutex() {
- ManagedStaticMutex = new std::recursive_mutex();
-}
static std::recursive_mutex *getManagedStaticMutex() {
- llvm::call_once(mutex_init_flag, initializeMutex);
- return ManagedStaticMutex;
+ static std::recursive_mutex m;
+ return &m;
}
void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83372.290240.patch
Type: text/x-patch
Size: 741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200907/e2b9b87a/attachment.bin>
More information about the llvm-commits
mailing list