Support allocations up to 32767 bytes in the pool-based allocator.

The previous limit was 4096 bytes, and trying to allocate more could lead to memory corruption. Raising the limit allows for longer string literals created via concatenation.
This commit is contained in:
Stephen Heumann 2021-10-11 22:22:24 -05:00
parent a888206111
commit ba944e5675
1 changed files with 10 additions and 4 deletions

14
MM.pas
View File

@ -168,8 +168,11 @@ var
begin {GMalloc}
if bytes > globalSize then begin {allocate a new pool, if needed}
globalSize := poolSize;
myhandle := NewHandle(poolSize, globalID, $C010, nil);
if bytes > poolSize then
globalSize := bytes
else
globalSize := poolSize;
myhandle := NewHandle(globalSize, globalID, $C010, nil);
if ToolError <> 0 then TermError(5);
globalPtr := myhandle^;
end; {if}
@ -209,8 +212,11 @@ var
begin {LMalloc}
if bytes > localSize then begin {allocate a new pool, if needed}
localSize := poolSize;
myhandle := NewHandle(poolSize, localID, $C010, nil);
if bytes > poolSize then
localSize := bytes
else
localSize := poolSize;
myhandle := NewHandle(localSize, localID, $C010, nil);
if ToolError <> 0 then TermError(5);
localPtr := myhandle^;
end; {if}