-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathufpcheap.pas
75 lines (60 loc) · 2.27 KB
/
ufpcheap.pas
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(******************************************************************************)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* This file is part of heapsim *)
(* *)
(* See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(******************************************************************************)
Unit ufpcheap;
{$MODE objfpc}{$H+}
Interface
Uses
Classes, SysUtils, ubaseHeap;
Type
{ TFPCHeap
Wrapper Class to adopt the FPC internal mechanisms to access
through the testing environment
}
TFPCHeap = Class(TBaseHeap)
protected
Function AllocatedByteCount(P: Pointer): integer; override;
public
Procedure ReCreate(); override;
Constructor Create(Size: uint32); override;
Function GetMem(size: ptruint): Pointer; override;
Function FreeMem(P: Pointer): ptruint; override;
End;
Implementation
{ TFPCHeap }
Function TFPCHeap.AllocatedByteCount(P: Pointer): integer;
Begin
{$WARNING das hier stimmt nicht so ganz, da system.memsize irgend etwas anderes (aber ähnliches) zurückgibt}
Result := system.MemSize(p);
End;
Procedure TFPCHeap.ReCreate;
Begin
Inherited ReCreate;
End;
Constructor TFPCHeap.Create(Size: uint32);
Begin
size := 1;
Inherited Create(size);
End;
Function TFPCHeap.GetMem(size: ptruint): Pointer;
Begin
Result := Inherited GetMem(size);
result := system.GetMem(size);
End;
Function TFPCHeap.FreeMem(P: Pointer): ptruint;
Begin
Result := Inherited FreeMem(P);
result := system.Freemem(p);
End;
End.