summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/memory2
-rw-r--r--libcxx/src/memory.cpp11
2 files changed, 8 insertions, 5 deletions
diff --git a/libcxx/include/memory b/libcxx/include/memory
index c01615469bf..4752ba0007d 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -2535,7 +2535,7 @@ public:
: __shared_owners_(__refs) {}
void __add_shared();
- void __release_shared();
+ bool __release_shared();
_LIBCPP_INLINE_VISIBILITY
long use_count() const {return __shared_owners_ + 1;}
};
diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp
index 9918531acc0..5bbf48e442c 100644
--- a/libcxx/src/memory.cpp
+++ b/libcxx/src/memory.cpp
@@ -50,11 +50,15 @@ __shared_count::__add_shared()
increment(__shared_owners_);
}
-void
+bool
__shared_count::__release_shared()
{
if (decrement(__shared_owners_) == -1)
+ {
__on_zero_shared();
+ return true;
+ }
+ return false;
}
__shared_weak_count::~__shared_weak_count()
@@ -65,7 +69,6 @@ void
__shared_weak_count::__add_shared()
{
__shared_count::__add_shared();
- __add_weak();
}
void
@@ -77,8 +80,8 @@ __shared_weak_count::__add_weak()
void
__shared_weak_count::__release_shared()
{
- __shared_count::__release_shared();
- __release_weak();
+ if (__shared_count::__release_shared())
+ __release_weak();
}
void
OpenPOWER on IntegriCloud