Browse Source

* 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 -
nickysn 4 năm trước cách đây
mục cha
commit
8e2e31f95c
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      rtl/wasi/sysheap.inc

+ 6 - 2
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;