mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 14:19:28 +02:00
+ added a simplified version of RegisterTinyHeapBlock, for use when the tiny
heap is a single memory block git-svn-id: trunk@28635 -
This commit is contained in:
parent
72ba70f7ec
commit
c8e9d2cf6e
@ -291,6 +291,31 @@
|
||||
{$endif DEBUG_TINY_HEAP}
|
||||
end;
|
||||
|
||||
procedure InternalTinyAlign(var AAddress: Pointer; ASize: PtrUInt);
|
||||
var
|
||||
alignment_inc: smallint;
|
||||
begin
|
||||
alignment_inc := TTinyHeapPointerArithmeticType(align(AAddress,TinyHeapAllocGranularity))-TTinyHeapPointerArithmeticType(AAddress);
|
||||
Inc(AAddress,alignment_inc);
|
||||
Dec(ASize,alignment_inc);
|
||||
Dec(ASize,ASize mod TinyHeapAllocGranularity);
|
||||
end;
|
||||
|
||||
{ Strongly simplified version of RegisterTinyHeapBlock, which can be used when
|
||||
the heap is only a single contiguous memory block. If you want to add
|
||||
multiple blocks to the heap, you should use RegisterTinyHeapBlock instead. }
|
||||
procedure RegisterTinyHeapBlock_Simple(AAddress: Pointer; ASize: PtrUInt);
|
||||
begin
|
||||
{$ifdef DEBUG_TINY_HEAP}
|
||||
Writeln('RegisterTinyHeapBlock_Simple(', HexStr(AAddress), ',', ASize, ')');
|
||||
{$endif DEBUG_TINY_HEAP}
|
||||
InternalTinyAlign(AAddress, ASize);
|
||||
HeapOrg:=AAddress;
|
||||
HeapPtr:=AAddress;
|
||||
FreeList:=AAddress;
|
||||
HeapEnd:=Pointer(TTinyHeapPointerArithmeticType(AAddress)+ASize);
|
||||
end;
|
||||
|
||||
procedure RegisterTinyHeapBlock(AAddress: pointer; ASize: ptruint);
|
||||
var
|
||||
alignment_inc: smallint;
|
||||
@ -299,10 +324,7 @@
|
||||
{$ifdef DEBUG_TINY_HEAP}
|
||||
Writeln('RegisterTinyHeapBlock(', HexStr(AAddress), ',', ASize, ')');
|
||||
{$endif DEBUG_TINY_HEAP}
|
||||
alignment_inc := TTinyHeapPointerArithmeticType(align(AAddress,TinyHeapAllocGranularity))-TTinyHeapPointerArithmeticType(AAddress);
|
||||
Inc(AAddress,alignment_inc);
|
||||
Dec(ASize,alignment_inc);
|
||||
Dec(ASize,ASize mod TinyHeapAllocGranularity);
|
||||
InternalTinyAlign(AAddress, ASize);
|
||||
if HeapOrg=nil then
|
||||
begin
|
||||
HeapOrg:=AAddress;
|
||||
|
@ -319,7 +319,7 @@ type
|
||||
{$endif}
|
||||
begin
|
||||
SetMemoryManager(TinyHeapMemoryManager);
|
||||
RegisterTinyHeapBlock(__nearheap_start, TPointerArithmeticType(__nearheap_end) - TPointerArithmeticType(__nearheap_start));
|
||||
RegisterTinyHeapBlock_Simple(__nearheap_start, TPointerArithmeticType(__nearheap_end) - TPointerArithmeticType(__nearheap_start));
|
||||
end;
|
||||
|
||||
function CheckLFN:boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user