Fixed missing counter increment in assign operator
This commit is contained in:
parent
18d0b316d4
commit
7e7d290008
|
@ -88,7 +88,7 @@ namespace Noux {
|
||||||
void _dec_ref_count()
|
void _dec_ref_count()
|
||||||
{
|
{
|
||||||
if (Shared_pointer_base::_dec_ref_count()) {
|
if (Shared_pointer_base::_dec_ref_count()) {
|
||||||
PDBG("ref count reached zero -> delete object");
|
PDBG("ref count for %p reached zero -> delete object", _ptr);
|
||||||
Genode::destroy(_alloc, _ptr);
|
Genode::destroy(_alloc, _ptr);
|
||||||
_ptr = 0;
|
_ptr = 0;
|
||||||
_alloc = 0;
|
_alloc = 0;
|
||||||
|
@ -107,7 +107,9 @@ namespace Noux {
|
||||||
}
|
}
|
||||||
|
|
||||||
Shared_pointer(Shared_pointer const & from)
|
Shared_pointer(Shared_pointer const & from)
|
||||||
: Shared_pointer_base(from._ref_counter), _ptr(from._ptr), _alloc(from._alloc)
|
:
|
||||||
|
Shared_pointer_base(from._ref_counter),
|
||||||
|
_ptr(from._ptr), _alloc(from._alloc)
|
||||||
{
|
{
|
||||||
_inc_ref_count();
|
_inc_ref_count();
|
||||||
}
|
}
|
||||||
|
@ -118,12 +120,16 @@ namespace Noux {
|
||||||
if (_ptr == from._ptr)
|
if (_ptr == from._ptr)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
/* forget about original pointed-to object */
|
||||||
_dec_ref_count();
|
_dec_ref_count();
|
||||||
|
|
||||||
_ref_counter = from._ref_counter;
|
_ref_counter = from._ref_counter;
|
||||||
_ptr = from._ptr;
|
_ptr = from._ptr;
|
||||||
_alloc = from._alloc;
|
_alloc = from._alloc;
|
||||||
|
|
||||||
|
/* account for newly assigned pointed-to object */
|
||||||
|
_inc_ref_count();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user