1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE a_modes.inc}
17 {$DEFINE MEM_DISABLE_ACCOUNTING}
20 interface
22 uses
23 SysUtils;
26 type
29 private
37 public
46 public
54 {$IF DEFINED(D2F_DEBUG) and NOT DEFINED(MEM_DISABLE_ACCOUNTING)}
57 {$ENDIF}
61 implementation
63 uses
64 hashtable;
66 type
68 public
74 THashPtrPtr = specialize THashBase<Pointer, PMemPool, THashKeyPtr>; // key: TClass; value: PMemPool
76 var
80 // ////////////////////////////////////////////////////////////////////////// //
81 class function THashKeyPtr.hash (const k: Pointer): LongWord; inline; begin result := fnvHash(PByte(@k)^, sizeof(k)); end;
82 class function THashKeyPtr.equ (const a, b: Pointer): Boolean; inline; begin result := (a = b); end;
87 begin
90 begin
98 // ////////////////////////////////////////////////////////////////////////// //
100 begin
111 procedure TMemPool.setCapacity (acount: Integer); // ensure capacity for at least `acount` objects
112 begin
117 begin
122 begin
132 begin
137 // ////////////////////////////////////////////////////////////////////////// //
138 {$IF DEFINED(D2F_DEBUG) and NOT DEFINED(MEM_DISABLE_ACCOUNTING)}
140 var
141 {$IF DEFINED(D2F_DEBUG) and NOT DEFINED(MEM_DISABLE_ACCOUNTING)}
143 {$ENDIF}
145 begin
146 {$IF DEFINED(D2F_DEBUG) and NOT DEFINED(MEM_DISABLE_ACCOUNTING)}
149 {$ELSE}
152 {$ENDIF}
159 var
161 begin
165 {$ENDIF}
168 // ////////////////////////////////////////////////////////////////////////// //
169 {$IF DEFINED(D2F_DEBUG) and NOT DEFINED(MEM_DISABLE_ACCOUNTING)}
171 var
174 begin
178 begin
183 {$ENDIF}
186 initialization
187 //mpoolMap := TMemPool.Create('textmap', 64);
188 finalization
189 {$IF DEFINED(D2F_DEBUG) and NOT DEFINED(MEM_DISABLE_ACCOUNTING)}
191 {$ENDIF}