Skip to content

Commit 2b2bcc5

Browse files
committed
Use zeroMemory over HEAPU8.fill. NFC
Also, add missing return statement to the legacy path in zeroMemory.
1 parent 9e37a10 commit 2b2bcc5

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/library.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ addToLibrary({
5858
for (var i = 0; i < size; i++) {
5959
HEAPU8[address + i] = 0;
6060
}
61-
return;
61+
return address;
6262
}
6363
#endif
64-
HEAPU8.fill(0, address, address + size);
65-
return address;
64+
return HEAPU8.fill(0, address, address + size);
6665
},
6766

6867
#if SAFE_HEAP

src/library_webgpu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ var LibraryWebGPU = {
20232023

20242024
// In webgpu.h offset and size are passed in as size_t.
20252025
// And library_webgpu assumes that size_t is always 32bit in emscripten.
2026-
wgpuBufferGetMappedRange__deps: ['$warnOnce', 'memalign', 'free'],
2026+
wgpuBufferGetMappedRange__deps: ['$warnOnce', '$zeroMemory', 'memalign', 'free'],
20272027
wgpuBufferGetMappedRange: (bufferId, offset, size) => {
20282028
var bufferWrapper = WebGPU.mgrBuffer.objects[bufferId];
20292029
{{{ gpu.makeCheckDefined('bufferWrapper') }}}
@@ -2052,7 +2052,7 @@ var LibraryWebGPU = {
20522052
}
20532053

20542054
var data = _memalign(16, mapped.byteLength);
2055-
HEAPU8.fill(0, data, mapped.byteLength);
2055+
zeroMemory(data, mapped.byteLength);
20562056
bufferWrapper.onUnmap.push(() => {
20572057
new Uint8Array(mapped).set(HEAPU8.subarray(data, data + mapped.byteLength));
20582058
_free(data);

0 commit comments

Comments
 (0)