Code cleanup, and fix some unsafe pointer handling in Network.

This commit is contained in:
Adam Ierymenko 2014-10-29 13:57:37 -07:00
parent f65b48d447
commit 95f421024a
10 changed files with 86 additions and 97 deletions

View file

@ -64,6 +64,20 @@ public:
++obj->__refCount;
}
SharedPtr(T *obj,bool runAwayFromZombies)
throw() :
_ptr(obj)
{
// HACK: this is used in "handlers" to take ownership of naked pointers,
// an ugly pattern that really ought to be factored out.
if (runAwayFromZombies) {
if ((int)(++obj->__refCount) < 2) {
--obj->__refCount;
_ptr = (T *)0;
}
} else ++obj->__refCount;
}
SharedPtr(const SharedPtr &sp)
throw() :
_ptr(sp._getAndInc())