Update language/tests/scripts/references/refsim.ring - Add: incLostOwnerCountOneLevel() function
@@ -413,26 +413,46 @@ func indirectCircularCount aMem,cVar
nIndirectCircularCount = nCount - nDirectCircularCount
return nIndirectCircularCount
-func incLostOwnerCount aMem,cVar,lKill
+func incLostOwnerCount aMem,cVar
nIndex = getVar(aMem,cVar)
aMem[nIndex][C_LOSTOWNERCOUNT]++
aMem[nIndex][C_STATUS] = :LOST
- if lKill
aChild = getNestedChildren(aMem,cVar)
- else
- aChild = getChildren(aMem,cVar)
+ lContineKill = True
+ for child in aChild
+ if child = NULL loop ok
+ nIndex = getVar(aMem,child)
+ if aMem[nIndex][C_VARNAME] != cVar
+ if ! ( aMem[nIndex][C_LOSTOWNERCOUNT] > aMem[nIndex][C_REFCOUNT] )
+ lContineKill = False
ok
+ ok
+ next
+ if ! lContineKill return ok
+ setRefCount(aMem,cVar,0)
+ freeRef(aMem,cVar)
for child in aChild
if child = NULL loop ok
nIndex = getVar(aMem,child)
if aMem[nIndex][C_VARNAME] != cVar
aMem[nIndex][C_LOSTOWNERCOUNT]++
- if lKill
if aMem[nIndex][C_LOSTOWNERCOUNT] > aMem[nIndex][C_REFCOUNT]
setRefCount(aMem,aMem[nIndex][C_VARNAME],0)
freeRef(aMem,aMem[nIndex][C_VARNAME])
ok
ok
+ next
+
+func incLostOwnerCountOneLevel aMem,cVar
+ nIndex = getVar(aMem,cVar)
+ aMem[nIndex][C_LOSTOWNERCOUNT]++
+ aMem[nIndex][C_STATUS] = :LOST
+ aChild = getChildren(aMem,cVar)
+ for child in aChild
+ if child = NULL loop ok
+ nIndex = getVar(aMem,child)
+ if aMem[nIndex][C_VARNAME] != cVar
+ aMem[nIndex][C_LOSTOWNERCOUNT]++
ok
next
@@ -450,11 +470,10 @@ func decrement aMem,cVar
# Circular Reference
# Check if this is the last owner where we can delete the reference
if getLostOwnerCount(aMem,cVar) >= nInDirectCount
- incLostOwnerCount(aMem,cVar,True)
- setRefCount(aMem,cVar,0)
- freeRef(aMem,cVar)
+ incLostOwnerCountOneLevel(aMem,cVar)
+ incLostOwnerCount(aMem,cVar)
else
- incLostOwnerCount(aMem,cVar,False)
+ incLostOwnerCountOneLevel(aMem,cVar)
ok
return
ok
