blob: ee8d76f54205316824c9b700fd922b9b6032ed22 (
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
|
{ Old file: tbs0292.pp }
{ objects not finalized when disposed OK 0.99.13 (FK) }
{$mode objfpc}
type
pobj = ^tobj;
tobj = object
a: ansistring;
constructor init(s: ansistring);
destructor done;
end;
PAnsiRec = ^TAnsiRec;
TAnsiRec = Packed Record
Maxlen,
len,
ref : Longint;
First : Char;
end;
const firstoff = sizeof(tansirec)-1;
var o: pobj;
t: ansistring;
constructor tobj.init(s: ansistring);
begin
a := s;
end;
destructor tobj.done;
begin
end;
const
s : string = ' with suffix';
var
refbefore : longint;
begin
t:='test'+s;
refbefore:=pansirec(pointer(t)-firstoff)^.ref;
writeln('refcount before init: ',pansirec(pointer(t)-firstoff)^.ref);
new(o,init(t));
writeln('refcount after init: ',pansirec(pointer(t)-firstoff)^.ref);
dispose(o,done);
writeln('refcount after done: ',pansirec(pointer(t)-firstoff)^.ref);
if refbefore<>pansirec(pointer(t)-firstoff)^.ref then
Halt(1);
end.
|