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