File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -565,17 +565,12 @@ type Memory interface {
565
565
// # Notes
566
566
//
567
567
// - This overflows (returns zero) if the memory has the maximum 65536 pages.
568
- // - Use Pages() to handle this corner case.
568
+ // As a workaround until wazero v2 to fix the return type, use Grow(0) to obtain the current pages and
569
+ // multiply by 65536.
569
570
//
570
571
// See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#-hrefsyntax-instr-memorymathsfmemorysize%E2%91%A0
571
572
Size () uint32
572
573
573
- // Pages returns the number of pages in the memory. 1 Page corresponds to 65536 bytes,
574
- // which is called "Page Size" in WebAssembly.
575
- //
576
- // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#memory-instances%E2%91%A0
577
- Pages () (pages uint32 )
578
-
579
574
// Grow increases memory by the delta in pages (65536 bytes per page).
580
575
// The return val is the previous memory size in pages, or false if the
581
576
// delta was ignored as it exceeds MemoryDefinition.Max.
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ func TestMemoryInstance_Grow_Size(t *testing.T) {
68
68
require .Equal (t , uint32 (5 ), res )
69
69
require .Equal (t , uint32 (9 ), m .Pages ())
70
70
71
+ res , ok = m .Grow (0 )
72
+ require .True (t , ok )
73
+ require .Equal (t , uint32 (9 ), res )
74
+ require .Equal (t , uint32 (9 ), m .Pages ())
75
+
71
76
// At this point, the page size equal 9,
72
77
// so trying to grow two pages should result in failure.
73
78
_ , ok = m .Grow (2 )
You can’t perform that action at this time.
0 commit comments