-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
bugSomething isn't workingSomething isn't workingcompletedIssue completed and committed to develop. To be closed on next releaseIssue completed and committed to develop. To be closed on next release
Description
The following code in the private SortResult
function of CountOccurences
causes a memory leak:
procedure SortResult(
var A: array of Generics.Collections.TPair<Integer,Cardinal>);
begin
Generics.Collections.TArray.Sort<
Generics.Collections.TPair<Integer,Cardinal>
>(
A,
Generics.Defaults.TDelegatedComparer<
Generics.Collections.TPair<Integer,Cardinal>
>.Create(
function (
const Left, Right: Generics.Collections.TPair<Integer,Cardinal>):
Integer
begin
Result := Left.Key - Right.Key;
end
)
);
end;
The fix is to create the comparer outside the method call:
procedure SortResult(
var A: array of Generics.Collections.TPair<Integer,Cardinal>);
var
Comparer: Generics.Defaults.IComparer<
Generics.Collections.TPair<Integer,Cardinal>
>;
begin
Comparer := Generics.Defaults.TDelegatedComparer<
Generics.Collections.TPair<Integer,Cardinal>
>.Create(
function (
const Left, Right: Generics.Collections.TPair<Integer,Cardinal>):
Integer
begin
Result := Left.Key - Right.Key;
end
);
Generics.Collections.TArray.Sort<
Generics.Collections.TPair<Integer,Cardinal>
>(A, Comparer);
end;
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompletedIssue completed and committed to develop. To be closed on next releaseIssue completed and committed to develop. To be closed on next release
Projects
Status
Completed