Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Fix deletion of pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Grund <alexander.grund@tu-dresden.de>
  • Loading branch information
Flamefire committed Nov 19, 2018
1 parent 49083b4 commit 898a4fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/sg14/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ struct retain_traits final {
template <class U>
static void decrement (reference_count<U>* ptr) noexcept {
static_assert(std::is_base_of_v<U, T>, "");
if (ptr->count -= 1) { delete static_cast<T*>(ptr); }
--ptr->count;
if (not use_count(ptr)) { delete static_cast<T*>(ptr); }
}
template <class U>
static long use_count (reference_count<U>* ptr) noexcept {
Expand Down

0 comments on commit 898a4fd

Please sign in to comment.