diff options
author | Jason Sams <rjsams@android.com> | 2011-08-18 18:01:33 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2011-08-18 18:01:33 -0700 |
commit | c7cec1e3577cc77a5a73d5bd5a82733b1b9936a1 (patch) | |
tree | 7b16f807f7f05630a96b1dbfb88676d0a889ff90 /rsObjectBase.cpp | |
parent | dc314a172d48479053f258b485d7d0284b5b5b1f (diff) | |
download | rs-c7cec1e3577cc77a5a73d5bd5a82733b1b9936a1.tar.gz |
Fix issue with freeing allocation with circular references.
Change-Id: I45871c20a192815eafee77f95e17a025f6dcf9d1
Diffstat (limited to 'rsObjectBase.cpp')
-rw-r--r-- | rsObjectBase.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp index f428f948..f5ced26e 100644 --- a/rsObjectBase.cpp +++ b/rsObjectBase.cpp @@ -81,6 +81,10 @@ void ObjectBase::incSysRef() const { void ObjectBase::preDestroy() const { } +bool ObjectBase::freeChildren() { + return false; +} + bool ObjectBase::checkDelete(const ObjectBase *ref) { if (!ref) { return false; @@ -217,6 +221,28 @@ void ObjectBase::zeroAllUserRef(Context *rsc) { } } +void ObjectBase::freeAllChildren(Context *rsc) { + if (rsc->props.mLogObjects) { + LOGV("Forcing release of all child objects."); + } + + // This operation can be slow, only to be called during context cleanup. + ObjectBase * o = (ObjectBase *)rsc->mObjHead; + while (o) { + if (o->freeChildren()) { + // deleted ref to self and possibly others, restart from head. + o = (ObjectBase *)rsc->mObjHead; + } else { + o = (ObjectBase *)o->mNext; + } + } + + if (rsc->props.mLogObjects) { + LOGV("Objects remaining."); + dumpAll(rsc); + } +} + void ObjectBase::dumpAll(Context *rsc) { asyncLock(); |