Browse Source

Fix `Set...()` methods leaking memory in ArrayList

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
3045c6904f
  1. 32
      sources/Data/Collections/ArrayList.uc

32
sources/Data/Collections/ArrayList.uc

@ -518,12 +518,16 @@ public final function ArrayList SetBool(
bool value, bool value,
optional bool asRef) optional bool asRef)
{ {
local AcediaObject newValue;
if (asRef) { if (asRef) {
SetItem(index, _.ref.bool(value)); newValue = _.ref.bool(value);
} }
else { else {
SetItem(index, _.box.bool(value)); newValue = _.box.bool(value);
} }
SetItem(index, newValue);
newValue.FreeSelf();
return self; return self;
} }
@ -581,12 +585,16 @@ public final function ArrayList SetByte(
byte value, byte value,
optional bool asRef) optional bool asRef)
{ {
local AcediaObject newValue;
if (asRef) { if (asRef) {
SetItem(index, _.ref.byte(value)); newValue = _.ref.byte(value);
} }
else { else {
SetItem(index, _.box.byte(value)); newValue = _.box.byte(value);
} }
SetItem(index, newValue);
newValue.FreeSelf();
return self; return self;
} }
@ -644,12 +652,16 @@ public final function ArrayList SetInt(
int value, int value,
optional bool asRef) optional bool asRef)
{ {
local AcediaObject newValue;
if (asRef) { if (asRef) {
SetItem(index, _.ref.int(value)); newValue = _.ref.int(value);
} }
else { else {
SetItem(index, _.box.int(value)); newValue = _.box.int(value);
} }
SetItem(index, newValue);
newValue.FreeSelf();
return self; return self;
} }
@ -707,12 +719,16 @@ public final function ArrayList SetFloat(
float value, float value,
optional bool asRef) optional bool asRef)
{ {
local AcediaObject newValue;
if (asRef) { if (asRef) {
SetItem(index, _.ref.float(value)); newValue = _.ref.float(value);
} }
else { else {
SetItem(index, _.box.float(value)); newValue = _.box.float(value);
} }
SetItem(index, newValue);
newValue.FreeSelf();
return self; return self;
} }

Loading…
Cancel
Save