I'm writing a multiplatform application in RAD 10.3.3 and i have an array manipulation problem
type
Tsex = (F,M);
Tcheckup = record
values : array of Tvalue;
name: string;
case integer of
0 : (minV : array[F..M] of word;
maxV : array[F..M] of word;
monada : byte;);
1 : (male : boolean);
end;
var deiktes : array of Tcheckup;
.....
// here i'm filling array "deiktes" with right values
....
// 0 < j < length(deiktes)
//here i try to delete the item j, so i move all the following one step up
// to overwrite the j item
move(deiktes[j+1],deiktes[j],(length(deiktes)-1-j)*sizeof(TCheckUp)); (1)
// and then decrease the length of the array
setLength(deiktes,length(deiktes)-1); (2)
In debug mode i can see that the array "values" is as must it be after deletion. But continuing the execution the last item has random values in the array "values" (but right value in the string "name") I suppose that either (1) or (2) functions free the pointer of the array "values" so, when the app needs to store something else, it uses the freed pointer's memory. If so, what can i do to avoid this please?
TList<TCheckup>instead.