Hi all
I am trying to run a old midi component in Delphi, and it works for the most part of it, but if I try loading 2 files in a row, it crashes.
some research led me to install EurekaLog, which point to memory leaks in the code.yay!
I'm not very good with memory pointers stuff, but this code down is highlighted by Eureka here got me thinking, maybe there is a bug with memory not being freed??
I tried adding FreeMem
at the end of it, but it doesn't work?
function TMidifile.ReadString(F: integer): string;
var
s: PChar;
i: integer;
begin
GetMem(s, F + 1);
s[F] := chr(0);
for i := 0 to F - 1 do
begin
s[i] := Chr(chunkIndex^);
inc(chunkIndex);
end;
result := string(s);
end;