diff options
-rw-r--r-- | absl/crc/BUILD.bazel | 2 | ||||
-rw-r--r-- | absl/crc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | absl/crc/internal/crc_cord_state.cc | 7 |
3 files changed, 6 insertions, 4 deletions
diff --git a/absl/crc/BUILD.bazel b/absl/crc/BUILD.bazel index f44c3f6b..d923aec4 100644 --- a/absl/crc/BUILD.bazel +++ b/absl/crc/BUILD.bazel @@ -182,8 +182,8 @@ cc_library( deps = [ ":crc32c", "//absl/base:config", + "//absl/base:no_destructor", "//absl/numeric:bits", - "//absl/strings", ], ) diff --git a/absl/crc/CMakeLists.txt b/absl/crc/CMakeLists.txt index ec7b4512..d52a1bc4 100644 --- a/absl/crc/CMakeLists.txt +++ b/absl/crc/CMakeLists.txt @@ -159,6 +159,7 @@ absl_cc_library( absl::crc32c absl::config absl::strings + absl::no_destructor ) absl_cc_test( diff --git a/absl/crc/internal/crc_cord_state.cc b/absl/crc/internal/crc_cord_state.cc index 28d04dc4..303a5559 100644 --- a/absl/crc/internal/crc_cord_state.cc +++ b/absl/crc/internal/crc_cord_state.cc @@ -17,6 +17,7 @@ #include <cassert> #include "absl/base/config.h" +#include "absl/base/no_destructor.h" #include "absl/numeric/bits.h" namespace absl { @@ -24,14 +25,14 @@ ABSL_NAMESPACE_BEGIN namespace crc_internal { CrcCordState::RefcountedRep* CrcCordState::RefSharedEmptyRep() { - static CrcCordState::RefcountedRep* empty = new CrcCordState::RefcountedRep; + static absl::NoDestructor<CrcCordState::RefcountedRep> empty; assert(empty->count.load(std::memory_order_relaxed) >= 1); assert(empty->rep.removed_prefix.length == 0); assert(empty->rep.prefix_crc.empty()); - Ref(empty); - return empty; + Ref(empty.get()); + return empty.get(); } CrcCordState::CrcCordState() : refcounted_rep_(new RefcountedRep) {} |