am 645434fb: Merge "Fix a leak in RefBase" into honeycomb-mr2

* commit '645434fb4eff408698423d70904fb8fc709a5225':
  Fix a leak in RefBase
This commit is contained in:
Mathias Agopian 2011-06-08 19:30:47 -07:00 committed by Android Git Automerger
commit 58d6631e4d

View File

@ -418,18 +418,20 @@ void RefBase::weakref_type::decWeak(const void* id)
if (c != 1) return; if (c != 1) return;
if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) {
if (impl->mStrong == INITIAL_STRONG_VALUE) if (impl->mStrong == INITIAL_STRONG_VALUE) {
if (impl->mBase) if (impl->mBase) {
impl->mBase->destroy(); impl->mBase->destroy();
else { }
} else {
// LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase);
delete impl; delete impl;
} }
} else { } else {
impl->mBase->onLastWeakRef(id); impl->mBase->onLastWeakRef(id);
if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) {
if (impl->mBase) if (impl->mBase) {
impl->mBase->destroy(); impl->mBase->destroy();
}
} }
} }
} }
@ -551,8 +553,10 @@ RefBase::RefBase()
RefBase::~RefBase() RefBase::~RefBase()
{ {
if (mRefs->mWeak == 0) { if ((mRefs->mFlags & OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK) {
delete mRefs; if (mRefs->mWeak == 0) {
delete mRefs;
}
} }
} }