The reason is that elements of array of any type higher than byte parameters are not well passed through to functions:
extract from my MemManager code:
Function:
Code: Select all
function MM_CheckBlocks(P1: ^byte; S1: word; P2: ^byte; S2: word): byte;
begin
Result := 0; // default: no adjacent blocks
if P1 = 0 then exit;
if P2 = 0 then exit;
if P1 = P2 then exit;
if P1 + S1 = P2 then Result := 1 // block P1 is adjacent beneath block P2
else
if P2 + S2 = P1 then Result := 2; // block P2 is adjacent beneath block P1
end;
Code: Select all
procedure FreeMem(var P: ^byte; ActualSize: word);
....
Tmp := MM_CheckBlocks(P, ActualSize, MM_FreeMemTable[I].Pointer, MM_FreeMemTable[I].Size);
...
The "MM_FreeMemTable" was declared as:
Code: Select all
Type TFreeMemBlock = record
Pointer: ^byte;
Size : Word;
end;
var MM_FreeMemTable: array[HEAP_NR_FREE_BLOCKS] of TFreeMemBlock;
Code: Select all
procedure FreeMem(var P: ^byte; ActualSize: word);
....
Tmp := MM_CheckBlocks(P, ActualSize, ^byte(MM_FreeMemTable[I].Pointer), MM_FreeMemTable[I].Size);
...
I did not test if the problem only occurs with record member arguments...
I think this is a major issue.