blob: 20824f97e8643d2eb5fa13861c76ce2ca00d2c69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
{ %opt=-ghl }
{ Source provided for Free Pascal Bug Report 3411 }
{ Submitted by "Dean Zobec" on 2004-11-28 }
{ e-mail: dezobec@tin.it }
{$mode objfpc}{$H+}
{$interfaces com}
program interfaceleak;
// compile with option -ghl
type
IMoney = interface
['{AAD734A1-6F35-D911-9C73-C6AC7996EDD0}']
function Add(aMoney: IMoney): IMoney;
end;
TMoney = class(TInterfacedObject, IMoney)
private
FAmount: Int64;
FCurrencyUnit: string;
public
function Add(aMoney: IMoney): IMoney;
constructor Create(aAmount: int64;
aUnit: string);
destructor Destroy; override;
end;
function TMoney.Add(aMoney: IMoney): IMoney;
begin
Result := nil;
end;
constructor TMoney.Create(aAmount: int64;
aUnit: string);
begin
Inherited Create;
FAmount := aAmount;
FCurrencyUnit := aUnit;
end;
destructor TMoney.Destroy;
begin
FCurrencyUnit := '';
writeln('Destroyed');
inherited Destroy;
end;
procedure TestLeak;
var
a: IMoney;
begin
a := TMoney.Create(12, 'EUR');
end;
begin
HaltOnNotReleased := true;
TestLeak;
end.
|