aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-04-29 22:03:56 +0900
committernsfisis <nsfisis@gmail.com>2024-04-29 22:13:31 +0900
commit327bf214fe0485d5d1a9de4963573c1c9ec1725e (patch)
tree452e112949fad9f331bd1d5c33b53f2eb4b72bc5 /src
parentb8d11855e22fa1637d809397ac75ee0c65e649ca (diff)
downloadphp-waddiwasi-327bf214fe0485d5d1a9de4963573c1c9ec1725e.tar.gz
php-waddiwasi-327bf214fe0485d5d1a9de4963573c1c9ec1725e.tar.zst
php-waddiwasi-327bf214fe0485d5d1a9de4963573c1c9ec1725e.zip
fix: memory.grow
Diffstat (limited to 'src')
-rw-r--r--src/Execution/MemInst.php8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/Execution/MemInst.php b/src/Execution/MemInst.php
index 7d1cc36..1be4860 100644
--- a/src/Execution/MemInst.php
+++ b/src/Execution/MemInst.php
@@ -98,15 +98,13 @@ final class MemInst
$originalSize = $this->size();
// @phpstan-ignore-next-line
- $originalData = $this->ffi->new("uint8_t[$originalSize]");
+ $originalData = $this->ffi->new("uint8_t[$originalSize+8]");
assert($originalData !== null);
+ FFI::memcpy($originalData, $this->dataU8, $originalSize);
$this->initInternalMemory($len);
- for ($i = 0; $i < $originalSize; $i++) {
- // @phpstan-ignore-next-line
- $this->dataU8[$i] = $originalData[$i];
- }
+ FFI::memcpy($this->dataU8, $originalData, $originalSize);
return $sz;
}