From 8e2e31f95c77b317bd236b993b057078bdf87f90 Mon Sep 17 00:00:00 2001 From: nickysn Date: Sat, 23 Jan 2021 06:40:45 +0000 Subject: [PATCH] * 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 - --- rtl/wasi/sysheap.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rtl/wasi/sysheap.inc b/rtl/wasi/sysheap.inc index a9034da597..73093c99ff 100644 --- a/rtl/wasi/sysheap.inc +++ b/rtl/wasi/sysheap.inc @@ -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;