In Delphi 10.4, I have a record
that I use like this in a TList
(System.Generics.Collections
):
uses
System.Generics.Collections;
type
TSomething = record
Name: String;
Foo: String;
Bar: String;
Group: String;
Flag1: Boolean;
Flag2: Boolean;
Flag3: Boolean;
Flag4: Boolean;
Flag5: Boolean;
end;
PTSomething = ^TSomething;
//Simplified code for readability...
var
Something: TSomething;
MyList := TList<TSomething>;
lRecP: PTSomething;
MyList := TList<TSomething>.Create;
while ACondition do
begin
Something.Name := 'Something';
//Fill the rest of the record
MyList.Add(Something); //Add is done in a while loop which result around 1000 items in MyList
end;
//Later...
for i := 0 to MyList.Count - 1 do
begin
if ACondition then
begin
lRecP := @MyList.List[i];
lRecP.Name := 'Modified'; //Items can be modified but never deleted
end;
end;
//Later...
MyList.Free;
Is my code prone to memory fragmentation? I have about 1000 records in my list that I will iterate through and maybe modify a string off the record once per record.
Would there be a better way to do what I want to do?