Browse Source

Fix not deallocating keys with `Empty()`

`AssociativeArray` did not deallocate keys for non-managed items on
`Empty()` call.
pull/8/head
Anton Tarasenko 3 years ago
parent
commit
79e60e670a
  1. 20
      sources/Data/Collections/AssociativeArray.uc

20
sources/Data/Collections/AssociativeArray.uc

@ -514,23 +514,23 @@ public function Empty(optional bool deallocateKeys)
{ {
if (!nextEntries[j].managed) continue; if (!nextEntries[j].managed) continue;
if (nextEntries[j].value == none) continue; if (nextEntries[j].value == none) continue;
if ( nextEntries[j].value.GetLifeVersion() nextEntries[j].value.FreeSelf(nextEntries[j].valueLifeVersion);
!= nextEntries[j].valueLifeVersion) {
continue;
} }
if (deallocateKeys) if (deallocateKeys)
{ {
for (j = 0; j < nextEntries.length; j += 1)
{
if (nextEntries[j].key == none) {
continue;
}
if ( nextEntries[j].key.GetLifeVersion()
!= nextEntries[j].keyLifeVersion) {
continue;
}
subCollection = Collection(nextEntries[j].value); subCollection = Collection(nextEntries[j].value);
if (subCollection != none) { if (subCollection != none) {
subCollection.Empty(true); subCollection.Empty(true);
} }
}
nextEntries[j].value.FreeSelf(nextEntries[j].valueLifeVersion);
}
if (deallocateKeys)
{
for (j = 0; j < nextEntries.length; j += 1)
{
if (nextEntries[j].key != none) { if (nextEntries[j].key != none) {
nextEntries[j].key.FreeSelf(nextEntries[j].keyLifeVersion); nextEntries[j].key.FreeSelf(nextEntries[j].keyLifeVersion);
} }

Loading…
Cancel
Save