diff options
Diffstat (limited to 'libs/kstd')
| -rw-r--r-- | libs/kstd/kstd/bits/shared_ptr.hpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/kstd/kstd/bits/shared_ptr.hpp b/libs/kstd/kstd/bits/shared_ptr.hpp index 8930095..57a89c0 100644 --- a/libs/kstd/kstd/bits/shared_ptr.hpp +++ b/libs/kstd/kstd/bits/shared_ptr.hpp @@ -21,7 +21,7 @@ namespace kstd std::atomic<std::size_t> shared_count; std::atomic<std::size_t> weak_count; - explicit shared_control_block(std::size_t shared = 1, std::size_t weak = 0) + explicit shared_control_block(std::size_t shared = 1, std::size_t weak = 1) : shared_count(shared) , weak_count(weak) {} @@ -146,7 +146,7 @@ namespace kstd { if (control != nullptr) { - if (--(control->weak_count) == 0 && control->shared_count == 0) + if (--(control->weak_count) == 0) { delete control; } @@ -579,7 +579,7 @@ namespace kstd delete pointer; pointer = nullptr; - if (control->weak_count == 0) + if (--(control->weak_count) == 0) { delete control; } |
