Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ caml_binaryen_get_memory_segment_byte_offset(value _module, value _name) {
CAMLparam2(_module, _name);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
char* name = Safe_String_val(_name);
CAMLreturn(Val_int(BinaryenGetMemorySegmentByteOffset(module, name)));
if (BinaryenGetMemorySegmentPassive(module, name)) {
CAMLreturn(Val_int(-1));
} else {
CAMLreturn(Val_int(BinaryenGetMemorySegmentByteOffset(module, name)));
}
}

CAMLprim value
Expand Down
3 changes: 3 additions & 0 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ let _ = Memory.set_memory max_memory_wasm_mod 1 2 "memory" [] false false "0"
let _ = assert (Memory.has_max max_memory_wasm_mod "0" = true)
let _ = assert (Memory.get_max max_memory_wasm_mod "0" = 2)

(* Memory.get_segment_byte_offset Passive *)
let _ = assert (Memory.get_segment_byte_offset wasm_mod "world" = -1)

let _ =
assert (
Bytes.equal
Expand Down
Loading