Autor Beitrag
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Mo 03.12.07 13:23 
Hallo zusammen,

ich wollte mal Fragen, ob das ein Speicherleck erzeugt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
TRecord = record
  a,b,c : Integer;
end;

TRecordArray = array of TRecord;

function Test() : TRecordArray;
var res : TRecordArray;
begin
  // Irgendwelche wunderbaren Berechnungen...
  SetLength(res,5);
  // res wird mit werten gefüllt

  Result := res;
end;

var x : TRecordArray;

begin
  x := Test();
  Schreibe(X);
end.


Ist das problematisch? Wenn ja, wie macht man es dann "richtig"?
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 03.12.07 13:28 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
begin
  x := Test();
  Schreibe(X);
  Finalize(X);
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!