mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 12:26:02 +02:00
+ RegisterTinyHeapBlock: align the start address and size according to
TinyHeapAllocGranularity git-svn-id: trunk@28418 -
This commit is contained in:
parent
815bfe0dcf
commit
902c25fafa
@ -261,17 +261,16 @@
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure RegisterTinyHeapBlock(AAddress: pointer; ASize: ptruint);
|
procedure RegisterTinyHeapBlock(AAddress: pointer; ASize: ptruint);
|
||||||
|
var
|
||||||
|
alignment_inc: smallint;
|
||||||
begin
|
begin
|
||||||
{$ifdef DEBUG_TINY_HEAP}
|
{$ifdef DEBUG_TINY_HEAP}
|
||||||
Writeln('RegisterTinyHeapBlock(', ptruint(AAddress), ',', ASize, ')');
|
Writeln('RegisterTinyHeapBlock(', ptruint(AAddress), ',', ASize, ')');
|
||||||
{$endif DEBUG_TINY_HEAP}
|
{$endif DEBUG_TINY_HEAP}
|
||||||
if (ptruint(AAddress) and 1) <> 0 then
|
alignment_inc := TTinyHeapPointerArithmeticType(align(AAddress,TinyHeapAllocGranularity))-TTinyHeapPointerArithmeticType(AAddress);
|
||||||
begin
|
Inc(AAddress,alignment_inc);
|
||||||
Inc(AAddress);
|
Dec(ASize,alignment_inc);
|
||||||
Dec(ASize);
|
Dec(ASize,ASize mod TinyHeapAllocGranularity);
|
||||||
end;
|
|
||||||
if (ASize and 1) <> 0 then
|
|
||||||
Dec(ASize);
|
|
||||||
PTinyHeapMemBlockSize(AAddress)^ := ASize - SizeOf(TTinyHeapMemBlockSize);
|
PTinyHeapMemBlockSize(AAddress)^ := ASize - SizeOf(TTinyHeapMemBlockSize);
|
||||||
FreeMem(Pointer(PTinyHeapMemBlockSize(AAddress) + 1), ASize - SizeOf(TTinyHeapMemBlockSize));
|
FreeMem(Pointer(PTinyHeapMemBlockSize(AAddress) + 1), ASize - SizeOf(TTinyHeapMemBlockSize));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user