github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/testing/binaryencoding/memory.go (about)

     1  package binaryencoding
     2  
     3  import (
     4  	"github.com/wasilibs/wazerox/internal/wasm"
     5  )
     6  
     7  // EncodeMemory returns the wasm.Memory encoded in WebAssembly 1.0 (20191205) Binary Format.
     8  //
     9  // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#binary-memory
    10  func EncodeMemory(i *wasm.Memory) []byte {
    11  	maxPtr := &i.Max
    12  	if !i.IsMaxEncoded {
    13  		maxPtr = nil
    14  	}
    15  	return EncodeLimitsType(i.Min, maxPtr, i.IsShared)
    16  }