[ozulis] custom memory management is near completion, but i still have a bug :/
[ozulis.git] / src / ozulis / core / ref-counted-object.cc
blob27947b0f28c8bea20293076a664d14770c61eae5
1 #include <ozulis/core/assert.hh>
3 #include "ref-counted-object.hh"
5 namespace ozulis
7 namespace core
9 RefCountedObject::~RefCountedObject()
13 void
14 RefCountedObject::use()
16 refCount_++;
17 printf("\e[0;32m%s:%p %d\e[m\n", __PRETTY_FUNCTION__, this, refCount_);
20 void
21 RefCountedObject::release()
23 assert(refCount_ > 0);
24 --refCount_;
25 printf("\e[0;31m%s:%p %d\e[m\n", __PRETTY_FUNCTION__, this, refCount_);
26 if (refCount_ == 0)
27 delete this;