* memory.grow returns the previous memory size in pages, so we don't need to ask for the size first in SysOSAlloc

git-svn-id: branches/wasm@48343 -
This commit is contained in:
nickysn 2021-01-23 06:40:45 +00:00
parent a6d332d092
commit 8e2e31f95c

View File

@ -24,9 +24,13 @@ function SysOSAlloc(size: ptruint): pointer;
const
page_size = 65536;
err = high(longword);
var
res: ptruint;
begin
SysOSAlloc:=pointer(fpc_wasm32_memory_size*page_size);
if fpc_wasm32_memory_grow((size + page_size - 1) div page_size) = err then
res:=fpc_wasm32_memory_grow((size + page_size - 1) div page_size);
if res<>err then
SysOSAlloc:=pointer(res*page_size)
else
SysOSAlloc:=nil;
end;