diff options
Diffstat (limited to 'absl')
-rw-r--r-- | absl/flags/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/flags/CMakeLists.txt | 1 | ||||
-rw-r--r-- | absl/flags/reflection.cc | 3 |
3 files changed, 4 insertions, 1 deletions
diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel index f51fdf75..170d1ba8 100644 --- a/absl/flags/BUILD.bazel +++ b/absl/flags/BUILD.bazel @@ -190,6 +190,7 @@ cc_library( ":private_handle_accessor", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:no_destructor", "//absl/container:flat_hash_map", "//absl/strings", "//absl/synchronization", diff --git a/absl/flags/CMakeLists.txt b/absl/flags/CMakeLists.txt index a535b55e..ddf2d4e7 100644 --- a/absl/flags/CMakeLists.txt +++ b/absl/flags/CMakeLists.txt @@ -169,6 +169,7 @@ absl_cc_library( absl::strings absl::synchronization absl::flat_hash_map + absl::no_destructor ) # Internal-only target, do not depend on directly. diff --git a/absl/flags/reflection.cc b/absl/flags/reflection.cc index dbce4032..841921a9 100644 --- a/absl/flags/reflection.cc +++ b/absl/flags/reflection.cc @@ -21,6 +21,7 @@ #include <string> #include "absl/base/config.h" +#include "absl/base/no_destructor.h" #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/flags/commandlineflag.h" @@ -169,7 +170,7 @@ void FlagRegistry::RegisterFlag(CommandLineFlag& flag, const char* filename) { } FlagRegistry& FlagRegistry::GlobalRegistry() { - static FlagRegistry* global_registry = new FlagRegistry; + static absl::NoDestructor<FlagRegistry> global_registry; return *global_registry; } |