diff options
author | rubidium <rubidium@openttd.org> | 2007-07-20 18:44:04 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-20 18:44:04 +0000 |
commit | 5083f22d1ddddd355d75a3d720fc2f5a3acd12a5 (patch) | |
tree | 5f1f70f105e1d48e5c98012e8393a7374f6668e7 /src/misc/countedobj.cpp | |
parent | 3f983ff1f227420eed715f4333a3055e9196eeef (diff) | |
download | openttd-5083f22d1ddddd355d75a3d720fc2f5a3acd12a5.tar.xz |
(svn r10644) -Merge (from NoAI): framework for reference counted objects (pointers).
Diffstat (limited to 'src/misc/countedobj.cpp')
-rw-r--r-- | src/misc/countedobj.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/misc/countedobj.cpp b/src/misc/countedobj.cpp new file mode 100644 index 000000000..a96537977 --- /dev/null +++ b/src/misc/countedobj.cpp @@ -0,0 +1,66 @@ +/* $Id$ */ + +#include "../stdafx.h" + +#include "countedptr.hpp" + +int32 SimpleCountedObject::AddRef() +{ + return ++m_ref_cnt; +} + +int32 SimpleCountedObject::Release() +{ + int32 res = --m_ref_cnt; + assert(res >= 0); + if (res == 0) { + FinalRelease(); + delete this; + } + return res; +} + +/* $Id$ */ + +#include "../stdafx.h" + +#include "countedptr.hpp" + +int32 SimpleCountedObject::AddRef() +{ + return ++m_ref_cnt; +} + +int32 SimpleCountedObject::Release() +{ + int32 res = --m_ref_cnt; + assert(res >= 0); + if (res == 0) { + FinalRelease(); + delete this; + } + return res; +} + +/* $Id$ */ + +#include "../stdafx.h" + +#include "countedptr.hpp" + +int32 SimpleCountedObject::AddRef() +{ + return ++m_ref_cnt; +} + +int32 SimpleCountedObject::Release() +{ + int32 res = --m_ref_cnt; + assert(res >= 0); + if (res == 0) { + FinalRelease(); + delete this; + } + return res; +} + |