Difference between revisions of "Unit HeapManager"

From Ultibo.org
Jump to: navigation, search
 
(8 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo Heap Manager interface unit'''
+
'''Ultibo Heap Manager Interface unit'''
 
+
''To be documented''
+
  
 
=== Constants ===
 
=== Constants ===
Line 17: Line 15:
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HEAP_MIN_BLOCK = 57;</code>
 +
| SizeOf(THeapBlock) + 1
 
|-
 
|-
 
| <code>HEAP_MIN_BLOCK = 33;</code>
 
| <code>HEAP_MIN_BLOCK = 33;</code>
Line 121: Line 122:
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HEAP_SMALL_MIN = 56;</code>
 +
| SizeOf(THeapBlock) Minimum size of a small heap block
 
|-
 
|-
 
| <code>HEAP_SMALL_MIN = 32;</code>
 
| <code>HEAP_SMALL_MIN = 32;</code>
Line 137: Line 141:
 
|-
 
|-
 
| <code>HEAP_SMALL_LOW = (HEAP_SMALL_MIN div HEAP_SMALL_ALIGN);</code>
 
| <code>HEAP_SMALL_LOW = (HEAP_SMALL_MIN div HEAP_SMALL_ALIGN);</code>
| 8
+
| 8 (32-bit) / 14 (64-bit)
 
|-
 
|-
 
| <code>HEAP_SMALL_HIGH = (HEAP_SMALL_MAX div HEAP_SMALL_ALIGN);</code>
 
| <code>HEAP_SMALL_HIGH = (HEAP_SMALL_MAX div HEAP_SMALL_ALIGN);</code>
Line 200: Line 204:
 
<code>PSmallBlocks = ^TSmallBlocks;</code>
 
<code>PSmallBlocks = ^TSmallBlocks;</code>
  
<code>TSmallBlocks = array[HEAP_SMALL_LOW..HEAP_SMALL_HIGH] of PHeapBlock; {8..1024}</code>
+
<code>TSmallBlocks = array[HEAP_SMALL_LOW..HEAP_SMALL_HIGH] of PHeapBlock;</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 389: Line 393:
 
|-
 
|-
 
| <code>RegisterCount:LongWord;</code>
 
| <code>RegisterCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''Reserve''
 +
|-
 +
| <code>ReserveCount:LongWord;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 470: Line 479:
 
|-
 
|-
 
|colspan="2"|''GetAligned Internal''
 
|colspan="2"|''GetAligned Internal''
 +
|-
 +
| <code>GetAlignedZeroCount:LongWord;</code>
 +
| &nbsp;
 
|-
 
|-
 
| <code>GetAlignedRemainCount:LongWord;</code>
 
| <code>GetAlignedRemainCount:LongWord;</code>
Line 490: Line 502:
 
|-
 
|-
 
| <code>GetAlignedRemoveFailCount:LongWord;</code>
 
| <code>GetAlignedRemoveFailCount:LongWord;</code>
| &nbsp;
 
|-
 
| <code>GetAlignedOrphanCount:LongWord;</code>
 
| &nbsp;
 
|-
 
| <code>GetAlignedOrphanBytes:LongWord;</code>
 
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 534: Line 540:
 
|-
 
|-
 
| <code>RegisterAddFailCount:LongWord;</code>
 
| <code>RegisterAddFailCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''Reserve Internal''
 +
|-
 +
| <code>ReserveInvalidCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReserveAddFailCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReserveSplitFailCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReserveRemoveFailCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReserveUnavailableCount:LongWord;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 572: Line 595:
 
|-
 
|-
 
| <code>GetLargeCount:LongWord;</code>
 
| <code>GetLargeCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FindFreeCount:LongWord;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 603: Line 629:
 
|colspan="2"|''Snapshot Properties''
 
|colspan="2"|''Snapshot Properties''
 
|-
 
|-
| <code>Adddress:PtrUInt;</code>
+
| <code>Address:PtrUInt;</code>
 
| Address of the Heap Block
 
| Address of the Heap Block
 
|-
 
|-
Line 658: Line 684:
 
! Note
 
! Note
 
| None documented
 
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function ReserveHeapBlock(Address:Pointer; Size:PtrUInt):Pointer;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Request the Heap Block specified by address and size be reserved from allocation</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Address
 +
| The starting address for the reservation. The memory manager may reserve a block that starts prior to the supplied address for alignment purposes.
 +
|-
 +
! Size
 +
| The total size in byte to be reserved, the memory manager may increase the amount reserved to cater for alignment or to prevent orphan blocks.
 +
Size must be greater than 0.
 +
|-
 +
! Return
 +
| A pointer to the actual reserved memory which may differ from the supplied starting address due to alignment. The reservation can be cancelled by passing the returned pointer to FreeMem.
 
|-
 
|-
 
|}
 
|}
Line 882: Line 927:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function GetAlignedMem(Size,Alignment:PtrUInt):Pointer;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function GetAlignedMem(Size,Alignment:PtrUInt):Pointer; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate a block of normal memory aligned on a multiple of the alignment value</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate a block of normal memory aligned on a multiple of the alignment value</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 899: Line 944:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 923: Line 968:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 947: Line 992:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 971: Line 1,016:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 995: Line 1,040:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,019: Line 1,064:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,043: Line 1,088:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,056: Line 1,101:
 
|-
 
|-
 
! Note
 
! Note
| None documented
+
| The memory must be freed using FreeIRQMem
 
|-
 
|-
 
|}
 
|}
Line 1,067: Line 1,112:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 +
|-
 +
! Note
 +
| The memory must be freed using FreeIRQMem
 
|-
 
|-
 
|}
 
|}
Line 1,080: Line 1,128:
 
|-
 
|-
 
! Note
 
! Note
| None documented
+
| The memory must be freed using FreeFIQMem
 
|-
 
|-
 
|}
 
|}
Line 1,091: Line 1,139:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 +
|-
 +
! Note
 +
| The memory must be freed using FreeFIQMem
 
|-
 
|-
 
|}
 
|}
Line 1,146: Line 1,197:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AllocAlignedMem(Size,Alignment:PtrUInt):Pointer;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function AllocAlignedMem(Size,Alignment:PtrUInt):Pointer; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate and clear a block of normal memory aligned on a multiple of the alignment value</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate and clear a block of normal memory aligned on a multiple of the alignment value</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,163: Line 1,214:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,170: Line 1,221:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function ReAllocAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function ReAllocAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Reallocate a block of normal memory aligned on a multiple of the alignment value</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Reallocate a block of normal memory aligned on a multiple of the alignment value</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,187: Line 1,238:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,211: Line 1,262:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,235: Line 1,286:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,259: Line 1,310:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,283: Line 1,334:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,331: Line 1,382:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,355: Line 1,406:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,379: Line 1,430:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,403: Line 1,454:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,427: Line 1,478:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,451: Line 1,502:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,475: Line 1,526:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
|}
 
|}
Line 1,499: Line 1,550:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
! Note
 
! Note
Line 1,515: Line 1,566:
 
|-
 
|-
 
! Note
 
! Note
| None documented
+
| The memory must be freed using FreeIRQMem
 
|-
 
|-
 
|}
 
|}
Line 1,526: Line 1,577:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 +
|-
 +
! Note
 +
| The memory must be freed using FreeIRQMem
 
|-
 
|-
 
|}
 
|}
Line 1,550: Line 1,604:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
 
|-
 
|-
 
! Note
 
! Note
Line 1,566: Line 1,620:
 
|-
 
|-
 
! Note
 
! Note
| None documented
+
| The memory must be freed using FreeFIQMem
 +
|-
 
|-
 
|-
 
|}
 
|}
Line 1,577: Line 1,632:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! Alignment
+
! Note
| The alignment must be a multiple of the minimum alignment configuration
+
| Alignment must be a power of 2
|-
+
|}
+
</div></div>
+
<br />
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
+
<pre style="border: 0; padding-bottom:0px;">function SizeIRQMem(Addr:Pointer):PtrUInt;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Return the size of an allocated block of IRQ memory</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
 
! Note
 
! Note
| None documented
+
| The memory must be freed using FreeFIQMem
 
|-
 
|-
 
|}
 
|}
Line 1,837: Line 1,883:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function GetFreeBlock(Size:PtrUInt):PHeapBlock;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function function GetFreeBlock(Size:PtrUInt):PHeapBlock; inline;(Size:PtrUInt):PHeapBlock; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get a free block of at least the size indicated</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get a free block of at least the size indicated</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
Line 2,189: Line 2,235:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function SysGetMem(Size:PtrUInt):Pointer;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function SysGetMem(Size:PtrUInt):Pointer; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate a block of normal memory</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate a block of normal memory</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
Line 2,231: Line 2,277:
 
|-
 
|-
 
! Note
 
! Note
| None documented
+
| Not inlined to AllocMemEx to save extra call from memory manager
 
|-
 
|-
 
|}
 
|}
Line 2,237: Line 2,283:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function SysReAllocMem(var Addr:Pointer; Size:PtrUInt):Pointer;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function SysReAllocMem(var Addr:Pointer; Size:PtrUInt):Pointer; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Reallocate a block of normal memory</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Reallocate a block of normal memory</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">

Latest revision as of 03:41, 10 January 2023

Return to Unit Reference


Description


Ultibo Heap Manager Interface unit

Constants



[Expand]
Heap specific constants HEAP_MIN_*


[Expand]
Heap signature HEAP_SIGNATURE_*


[Expand]
Heap block state HEAP_STATE_*


[Expand]
Heap block flag HEAP_FLAG_*


[Expand]
Heap small block HEAP_SMALL_*


Type definitions



Heap callback

THeapCallback = function(Size:PtrUInt):LongWord;

Heap block

[Expand]

PHeapBlock = ^THeapBlock;

THeapBlock = record

Heap small blocks

[Expand]

PSmallBlocks = ^TSmallBlocks;

TSmallBlocks = array[HEAP_SMALL_LOW..HEAP_SMALL_HIGH] of PHeapBlock;

Heap lock

[Expand]

PHeapLock = ^THeapLock;

THeapLock = record

Heap statistics

[Expand]

PHeapStatistics = ^THeapStatistics;

THeapStatistics = record

Heap snapshot

[Expand]

PHeapSnapshot = ^THeapSnapshot;

THeapSnapshot = record


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure RegisterMemoryManager;
Description: To be documented


[Expand]
procedure RegisterHeapBlock(Address:Pointer; Size:PtrUInt);
Description: To be documented


[Expand]
function ReserveHeapBlock(Address:Pointer; Size:PtrUInt):Pointer;
Description: Request the Heap Block specified by address and size be reserved from allocation


[Expand]
function RequestHeapBlock(Hint:Pointer; Size:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Request registration a Heap Block with specified flags and affinity within an existing block


[Expand]
function RequestSharedHeapBlock(Hint:Pointer; Size:PtrUInt):Pointer;
Description: Request registration of a Shared Heap Block within an existing block


[Expand]
function RequestLocalHeapBlock(Hint:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Request registration of a Local Heap Block within an existing block


[Expand]
function RequestCodeHeapBlock(Hint:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Request registration of a Code Heap Block within an existing block


[Expand]
function RequestDeviceHeapBlock(Hint:Pointer; Size:PtrUInt):Pointer;
Description: Request registration of a Device Heap Block within an existing block


[Expand]
function RequestNoCacheHeapBlock(Hint:Pointer; Size:PtrUInt):Pointer;
Description: Request registration of a Non Cached Heap Block within an existing block


[Expand]
function RequestNonSharedHeapBlock(Hint:Pointer; Size:PtrUInt):Pointer;
Description: Request registration of a Non Shared Heap Block within an existing block


[Expand]
function RequestIRQHeapBlock(Hint:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Request registration of an IRQ Heap Block within an existing block


[Expand]
function RequestFIQHeapBlock(Hint:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Request registration of an FIQ Heap Block within an existing block


Heap functions

[Expand]
function GetMemEx(Size:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Allocate a block of memory with the flags and affinity requested


[Expand]
function GetAlignedMem(Size,Alignment:PtrUInt):Pointer; inline;
Description: Allocate a block of normal memory aligned on a multiple of the alignment value


[Expand]
function GetAlignedMemEx(Size,Alignment:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Allocate a block of memory aligned on a multiple of the alignment value with the flags and affinity requested


[Expand]
function GetSharedMem(Size:PtrUInt):Pointer;
Description: Allocate a block of shared memory


[Expand]
function GetSharedAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate a block of shared memory aligned on a multiple of the alignment value


[Expand]
function GetLocalMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of local memory


[Expand]
function GetLocalAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of local memory aligned on a multiple of the alignment value


[Expand]
function GetCodeMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of code memory


[Expand]
function GetCodeAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of code memory aligned on a multiple of the alignment value


[Expand]
function GetDeviceMem(Size:PtrUInt):Pointer;
Description: Allocate a block of device memory


[Expand]
function GetDeviceAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate a block of device memory aligned on a multiple of the alignment value


[Expand]
function GetNoCacheMem(Size:PtrUInt):Pointer;
Description: Allocate a block of non cached memory


[Expand]
function GetNoCacheAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate a block of non cached memory aligned on a multiple of the alignment value


[Expand]
function GetNonSharedMem(Size:PtrUInt):Pointer;
Description: Allocate a block of non shared memory


[Expand]
function GetNonSharedAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate a block of non shared memory aligned on a multiple of the alignment value


[Expand]
function GetIRQMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of IRQ memory


[Expand]
function GetIRQAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of IRQ memory aligned on a multiple of the alignment value


[Expand]
function GetFIQMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of FIQ memory


[Expand]
function GetFIQAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate a block of FIQ memory aligned on a multiple of the alignment value


[Expand]
function FreeIRQMem(Addr:Pointer):PtrUInt;
Description: Free a block of IRQ memory


[Expand]
function FreeFIQMem(Addr:Pointer):PtrUInt;
Description: Free a block of FIQ memory


[Expand]
function AllocMemEx(Size:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Allocate and clear a block of memory with the flags and affinity requested


[Expand]
function ReAllocMemEx(var Addr:Pointer; Size:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Reallocate a block of memory with the flags and affinity requested


[Expand]
function AllocAlignedMem(Size,Alignment:PtrUInt):Pointer; inline;
Description: Allocate and clear a block of normal memory aligned on a multiple of the alignment value


[Expand]
function AllocAlignedMemEx(Size,Alignment:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Allocate and clear a block of normal memory aligned on a multiple of the alignment value with the flags and affinity requested


[Expand]
function ReAllocAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer; inline;
Description: Reallocate a block of normal memory aligned on a multiple of the alignment value


[Expand]
function ReAllocAlignedMemEx(var Addr:Pointer; Size,Alignment:PtrUInt; Flags,Affinity:LongWord):Pointer;
Description: Reallocate a block of memory aligned on a multiple of the alignment value with the flags and affinity requested


[Expand]
function AllocSharedMem(Size:PtrUInt):Pointer;
Description: Allocate and clear a block of shared memory


[Expand]
function AllocSharedAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate and clear a block of shared memory aligned on a multiple of the alignment value


[Expand]
function ReAllocSharedMem(var Addr:Pointer; Size:PtrUInt):Pointer;
Description: Reallocate a block of shared memory


[Expand]
function ReAllocSharedAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer;
Description: Reallocate a block of shared memory aligned on a multiple of the alignment value


[Expand]
function AllocLocalMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of local memory


[Expand]
function AllocLocalAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of local memory aligned on a multiple of the alignment value


[Expand]
function ReAllocLocalMem(var Addr:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of local memory


[Expand]
function ReAllocLocalAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of local memory aligned on a multiple of the alignment value


[Expand]
function AllocCodeMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of code memory


[Expand]
function AllocCodeAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of code memory aligned on a multiple of the alignment value


[Expand]
function ReAllocCodeMem(var Addr:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of code memory


[Expand]
function ReAllocCodeAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of code memory aligned on a multiple of the alignment value


[Expand]
function AllocDeviceMem(Size:PtrUInt):Pointer;
Description: Allocate and clear a block of device memory


[Expand]
function AllocDeviceAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate and clear a block of device memory aligned on a multiple of the alignment value


[Expand]
function ReAllocDeviceMem(var Addr:Pointer; Size:PtrUInt):Pointer;
Description: Reallocate a block of device memory


[Expand]
function ReAllocDeviceAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer;
Description: Reallocate a block of device memory aligned on a multiple of the alignment value


[Expand]
function AllocNoCacheMem(Size:PtrUInt):Pointer;
Description: Allocate and clear a block of non cached memory


[Expand]
function AllocNoCacheAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate and clear a block of non cached memory aligned on a multiple of the alignment value


[Expand]
function ReAllocNoCacheMem(var Addr:Pointer; Size:PtrUInt):Pointer;
Description: Reallocate a block of non cached memory


[Expand]
function ReAllocNoCacheAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer;
Description: Reallocate a block of non cached memory aligned on a multiple of the alignment value


[Expand]
function AllocNonSharedMem(Size:PtrUInt):Pointer;
Description: Allocate and clear a block of non shared memory


[Expand]
function AllocNonSharedAlignedMem(Size,Alignment:PtrUInt):Pointer;
Description: Allocate and clear a block of non shared memory aligned on a multiple of the alignment value


[Expand]
function ReAllocNonSharedMem(var Addr:Pointer; Size:PtrUInt):Pointer;
Description: Reallocate a block of non shared memory


[Expand]
function ReAllocNonSharedAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt):Pointer;
Description: Reallocate a block of non shared memory aligned on a multiple of the alignment value


[Expand]
function AllocIRQMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of IRQ memory


[Expand]
function AllocIRQAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of IRQ memory aligned on a multiple of the alignment value


[Expand]
function ReAllocIRQMem(var Addr:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of IRQ memory


[Expand]
function ReAllocIRQAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of IRQ memory aligned on a multiple of the alignment value


[Expand]
function AllocFIQMem(Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of FIQ memory


[Expand]
function AllocFIQAlignedMem(Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Allocate and clear a block of FIQ memory aligned on a multiple of the alignment value


[Expand]
function ReAllocFIQMem(var Addr:Pointer; Size:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of FIQ memory


[Expand]
function ReAllocFIQAlignedMem(var Addr:Pointer; Size,Alignment:PtrUInt; Affinity:LongWord):Pointer;
Description: Reallocate a block of FIQ memory aligned on a multiple of the alignment value


[Expand]
function SizeFIQMem(Addr:Pointer):PtrUInt;
Description: Return the size of an allocated block of FIQ memory


[Expand]
function MemFlags(Addr:Pointer):LongWord;
Description: Return the flags of an allocated block of memory


[Expand]
function MemFlagsIRQ(Addr:Pointer):LongWord;
Description: Return the flags of an allocated block of IRQ memory


[Expand]
function MemFlagsFIQ(Addr:Pointer):LongWord;
Description: Return the flags of an allocated block of FIQ memory


[Expand]
function GetHeapStatistics:THeapStatistics;
Description: Return detailed statistics for the heap manager


[Expand]
function GetHeapBlockCount(State:LongWord):LongWord;
Description: Get the total number of current heap blocks based on state


[Expand]
function GetHeapBlockCountEx(State,Flags,Affinity:LongWord):LongWord;
Description: Get the number of current heap blocks based on state, flags and affinity


[Expand]
function GetHeapBlockMin(State:LongWord):LongWord;
Description: Get the minimum size of current heap blocks based on state


[Expand]
function GetHeapBlockMinEx(State,Flags,Affinity:LongWord):LongWord;
Description: Get the minimum size of current heap blocks based on state, flags and affinity


[Expand]
function GetHeapBlockMax(State:LongWord):LongWord;
Description: Get the maximum size of current heap blocks based on state


[Expand]
function GetHeapBlockMaxEx(State,Flags,Affinity:LongWord):LongWord;
Description: Get the maximum size of current heap blocks based on state, flags and affinity


[Expand]
function CreateHeapSnapshot(State:LongWord):PHeapSnapshot;
Description: To be documented


[Expand]
function CreateHeapSnapshotEx(State,Flags,Affinity:LongWord):PHeapSnapshot;
Description: To be documented


[Expand]
function DestroyHeapSnapshot(Snapshot:PHeapSnapshot):LongWord;
Description: To be documented


Internal functions

[Expand]
function GetHeapBlock(Address:Pointer):PHeapBlock;
Description: Get the Heap Block referenced by Address


[Expand]
function FindHeapBlock(Address:Pointer; Size:PtrUInt):PHeapBlock;
Description: Find the Heap Block containing Address up to the Size specified


[Expand]
function AddHeapBlock(Block:PHeapBlock):Boolean;
Description: Add a heap block, sorted by ascending Address order


[Expand]
function SplitHeapBlock(Block:PHeapBlock; Size:PtrUInt):PHeapBlock;
Description: Split a heap block at the size indicated


[Expand]
function MergeHeapBlock(Block:PHeapBlock):PHeapBlock;
Description: Merge a heap block with Prev or Next blocks if free


[Expand]
function function GetFreeBlock(Size:PtrUInt):PHeapBlock; inline;(Size:PtrUInt):PHeapBlock; inline;
Description: Get a free block of at least the size indicated


[Expand]
function GetFreeBlockEx(Size:PtrUInt; Flags,Affinity:LongWord):PHeapBlock;
Description: Get a free block of at least the size indicated with the flags and affinity requested


[Expand]
function FindFreeBlock(Size:PtrUInt):PHeapBlock;
Description: Find a free block of at least the size indicated with no flags or affinity which is alignable to the HEAP_REQUEST_ALIGNMENT value


[Expand]
function AddFreeBlock(Block:PHeapBlock):Boolean;
Description: Add a free block, sorted by ascending Size order


[Expand]
function RemoveFreeBlock(Block:PHeapBlock):Boolean;
Description: Remove a free block


[Expand]
function GetUsedBlock(Address:Pointer):PHeapBlock;
Description: Get a used block by address


[Expand]
function CheckUsedBlock(Address:Pointer):Boolean; inline;
Description: Check a used block by address


[Expand]
function AddUsedBlock(Block:PHeapBlock):Boolean;
Description: Add a used block


[Expand]
function RemoveUsedBlock(Block:PHeapBlock):Boolean;
Description: Remove a used block


[Expand]
function GetIRQBlock(Address:Pointer):PHeapBlock;
Description: Get the IRQ Heap Block referenced by Address


[Expand]
function CheckIRQBlock(Address:Pointer):Boolean;
Description: Check the IRQ Heap Block referenced by Address


[Expand]
function AddIRQBlock(Block:PHeapBlock):Boolean;
Description: Add an IRQ heap block, sorted by ascending Address order


[Expand]
function SplitIRQBlock(Block:PHeapBlock; Size:PtrUInt):PHeapBlock;
Description: Split an IRQ heap block at the size indicated


[Expand]
function MergeIRQBlock(Block:PHeapBlock):PHeapBlock;
Description: Merge an IRQ heap block with Prev or Next blocks if free


[Expand]
function GetFreeIRQBlock(Size:PtrUInt; Affinity:LongWord):PHeapBlock;
Description: Get a free IRQ block of at least the size indicated


[Expand]
function AddFreeIRQBlock(Block:PHeapBlock):Boolean;
Description: Add a free IRQ block, sorted by ascending Size order


[Expand]
function RemoveFreeIRQBlock(Block:PHeapBlock):Boolean;
Description: Remove a free IRQ block


[Expand]
function GetFIQBlock(Address:Pointer):PHeapBlock;
Description: Get the FIQ Heap Block referenced by Address


[Expand]
function CheckFIQBlock(Address:Pointer):Boolean;
Description: Check the FIQ Heap Block referenced by Address


[Expand]
function AddFIQBlock(Block:PHeapBlock):Boolean;
Description: Add an FIQ heap block, sorted by ascending Address order


[Expand]
function SplitFIQBlock(Block:PHeapBlock; Size:PtrUInt):PHeapBlock;
Description: Split an FIQ heap block at the size indicated


[Expand]
function MergeFIQBlock(Block:PHeapBlock):PHeapBlock;
Description: Merge an FIQ heap block with Prev or Next blocks if free


[Expand]
function GetFreeFIQBlock(Size:PtrUInt; Affinity:LongWord):PHeapBlock;
Description: Get a free FIQ block of at least the size indicated


[Expand]
function AddFreeFIQBlock(Block:PHeapBlock):Boolean;
Description: Add a free FIQ block, sorted by ascending Size order


[Expand]
function RemoveFreeFIQBlock(Block:PHeapBlock):Boolean;
Description: Remove a free FIQ block


RTL heap manager functions

[Expand]
function SysGetMem(Size:PtrUInt):Pointer; inline;
Description: Allocate a block of normal memory


[Expand]
function SysFreeMem(Addr:Pointer):PtrUInt;
Description: Free a block of memory


[Expand]
function SysFreeMemSize(Addr:Pointer; Size:PtrUInt):PtrUInt;
Description: Free a block of memory


[Expand]
function SysAllocMem(Size:PtrUInt):Pointer;
Description: Allocate and clear a block of normal memory


[Expand]
function SysReAllocMem(var Addr:Pointer; Size:PtrUInt):Pointer; inline;
Description: Reallocate a block of normal memory


[Expand]
function SysSizeMem(Addr:Pointer):PtrUInt;
Description: Return the size of an allocated block of memory


[Expand]
procedure SysInitThread;
Description: Initialize thread specific heap information


[Expand]
procedure SysDoneThread;
Description: Finalize thread specific heap information


[Expand]
procedure SysRelocateHeap;
Description: Relocate heap data


[Expand]
function SysGetHeapStatus:THeapStatus;
Description: Return status information for the heap manager


[Expand]
function SysGetFPCHeapStatus:TFPCHeapStatus;
Description: Return status information for the heap manager


Helper functions

[Expand]
procedure AcquireHeapLock; inline;
Description: To be documented


[Expand]
procedure ReleaseHeapLock; inline;
Description: To be documented


[Expand]
procedure AcquireHeapIRQLock; inline;
Description: To be documented


[Expand]
procedure ReleaseHeapIRQLock; inline;
Description: To be documented


[Expand]
procedure AcquireHeapFIQLock; inline;
Description: To be documented


[Expand]
procedure ReleaseHeapFIQLock; inline;
Description: To be documented


[Expand]
procedure RegisterHeapLock(const Lock:THeapLock);
Description: To be documented


[Expand]
function HeapStateToString(State:LongWord):String;
Description: To be documented


Return to Unit Reference