History log of /wasmtime-44.0.1/examples/externref.c (Results 1 – 17 of 17)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7, v43.0.0, v42.0.1, v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3, v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1, v40.0.0, v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3, v38.0.2, v38.0.1, v37.0.2
# adff9d9d 07-Oct-2025 Alex Crichton <[email protected]>

Fix externref/anyref ownership in C/C++ API (#11799)

* Fix externref/anyref ownership in C/C++ API

This commit is a follow-up to #11514 which was discovered through
failing tests in the wasmtime-py

Fix externref/anyref ownership in C/C++ API (#11799)

* Fix externref/anyref ownership in C/C++ API

This commit is a follow-up to #11514 which was discovered through
failing tests in the wasmtime-py repository when updating to Wasmtime
37.0.0. Effectively a combination of bugs in the Rust API meant that it
wasn't possible to use `externref` or `anyref` bindings correctly. The
Rust changes in this commit are:

* `wasmtime_val_unroot` correctly drops the value now as opposed to
effectively being a noop from before (typo of using `as_externref` vs
`from_externref`).
* `wasmtime_{anyref,externref,val}_t` now have a `Drop` implementation
in Rust to correctly drop them if a value in Rust is dropped. This is
required to correctly manage memory in the `wasmtime_func_{call,new}`
implementations, for example.
* `wasmtime_{anyref,externref,val}_clone` no longer have an unnecessary
context parameter.
* `wasmtime_{anyref,externref,val}_unroot` no longer have an unnecessary
context parameter.

Changes in the C/C++ APIs are:

* `Result::{ok,err}_ref` APIs were added in addition to the preexisting
rvalue accessors.
* Loading/storing typed arguments now has an overload for `const T&` and
`T&&` which behaves differently. Notably transferring ownership for
`T&&` and not for `const T&`. This means that passing parameters when
calling a wasm function uses `const T&`, but passing results from a
host import uses `T&&`.
* `TypedFunc::call` now uses `const Params&` instead of `Params` to
explicitly specify it doesn't modify the parameters and forces using
the `const T&` store method.
* `Store::gc` is now a convenience method for `store.context().gc()`
* `ExternRef`, `AnyRef`, and `Val` now have ownership semantics and
destructors. This matches the spirit of #11514 for Rust but models it
in C++ as well. This required filling out move/copy
constructors/assignments.
* The explicit `ExternRef` now takes `std::any` instead of `T`.
* Minor issues related to ownership are fixed in `Val` bindings.

Valgrind was used to ensure that there were no leaks for the test suite
which additionally resulted in a number of `*_delete` calls being added
to tests using the C API (accidental omissions).

The original goal of this change was to be a patch release for 37.0.1 to
enable updating wasmtime-py to the 37.0.x releases of Wasmtime. In the
end though the changes here were broad enough that I no longer feel that
this is a good idea, so wasmtime-py will be skipping the 37 version of
Wasmtime.

* Run `clang-format`

prtest:full

show more ...


Revision tags: v37.0.1, v37.0.0, v36.0.2, v36.0.1, v36.0.0, v35.0.0, v24.0.4, v33.0.2, v34.0.2
# 57ba95e9 30-Jun-2025 Masashi Yoshimura <[email protected]>

Fixed bugs in the C thread example program and updated some comments for build command. (#11155)

* Remove the cargo command for examples/*.c and fix thread example code.

* Add _GNU_SOURCE.


Revision tags: v34.0.1, v33.0.1, v24.0.3, v32.0.1, v34.0.0, v33.0.0, v32.0.0, v31.0.0, v30.0.2, v30.0.1, v30.0.0, v29.0.1, v29.0.0, v28.0.1, v28.0.0, v27.0.0, v26.0.1, v25.0.3, v24.0.2, v26.0.0, v21.0.2, v22.0.1, v23.0.3, v25.0.2, v24.0.1, v25.0.1, v25.0.0, v24.0.0, v23.0.2, v23.0.1, v23.0.0, v22.0.0, v21.0.1, v21.0.0, v20.0.2, v20.0.1
# 77405cc8 24-Apr-2024 Alex Crichton <[email protected]>

c-api: Remove allocations from `wasmtime_val_t` (#8451)

* c-api: Remove allocations from `wasmtime_val_t`

This commit redesigns how GC references work in the C API. previously
`wasmtime_{any,extern

c-api: Remove allocations from `wasmtime_val_t` (#8451)

* c-api: Remove allocations from `wasmtime_val_t`

This commit redesigns how GC references work in the C API. previously
`wasmtime_{any,extern}ref_t` were both opaque pointers in the C API
represented as a `Box`. Wasmtime did not, however, provide the ability
to deallocate just the `Box` part. This was intended to be handled with
unrooting APIs but unrooting requires a `wasmtime_context_t` parameter,
meaning that destructors of types in other languages don't have a
suitable means of managing the memory around the
`wasmtime_{any,extern}ref_t` which might lead to leaks.

This PR takes an alternate approach for the representation of these
types in the C API. Instead of being an opaque pointer they're now
actual structures with definitions in the header file. These structures
mirror the internals in Rust and Rust is tagged to ensure that changes
are reflected in the C API as well. This is similar to how
`wasmtime_func_t` matches `wasmtime::Func`. This enables embedders to
not need to worry about memory management of these values outside of the
manual rooting otherwise required.

The hope is that this will reduce the likelihood of memory leaks and
otherwise not make it any harder to manage references in the C API.

* Run clang-format

* Review comments

* Replace macros with inline functions

* Add explicit accessors/constructors for the C API

* Fix C example

* Fix doc link

* Fix some doc issues

prtest:full

* Fix doxygen links

show more ...


Revision tags: v20.0.0
# 81d71873 19-Apr-2024 Alex Crichton <[email protected]>

Fix use-after-free in externref example (#8410)

* Fix use-after-free in externref example

This fixes a typo in the `externref.c` example where a deallocated
`wasmtime_val_t` was used by accident. A

Fix use-after-free in externref example (#8410)

* Fix use-after-free in externref example

This fixes a typo in the `externref.c` example where a deallocated
`wasmtime_val_t` was used by accident. Additionally this introduces
scoping to prevent this from arising again.

* Run clang-format

* Fix compilation of C example

show more ...


# 23640b6c 13-Apr-2024 Nick Fitzgerald <[email protected]>

wasmtime-c-api: Add support for GC references in `wasmtime.h` APIs (#8346)

Restores support for `externref` in `wasmtime_val_t`, methods for manipulating
them and getting their wrapped host data, an

wasmtime-c-api: Add support for GC references in `wasmtime.h` APIs (#8346)

Restores support for `externref` in `wasmtime_val_t`, methods for manipulating
them and getting their wrapped host data, and examples/tests for these things.

Additionally adds support for `anyref` in `wasmtime_val_t`, clone/delete methods
similar to those for `externref`, and a few `i31ref`-specific methods. Also adds
C and Rust example / test for working with `anyref`.

show more ...


Revision tags: v17.0.3, v19.0.2, v18.0.4, v19.0.1, v19.0.0, v18.0.3, v18.0.2, v17.0.2, v18.0.1, v18.0.0, v17.0.1, v17.0.0
# 93580f24 22-Jan-2024 Bruce Mitchener <[email protected]>

examples: Don't `fread()` within `assert(...)`. (#7803)

This is fine in debug builds but release builds without assertions
results in the file data not being read.


Revision tags: v16.0.0, v15.0.1
# f8fee938 29-Nov-2023 Tyler Rockwood <[email protected]>

add clang format (#7601)

* add clang-format

We chose WebKit style because out of all the builtin styles it seems the
closest to what already exists in wasmtime.

Signed-off-by: Tyler Rockwood <rock

add clang format (#7601)

* add clang-format

We chose WebKit style because out of all the builtin styles it seems the
closest to what already exists in wasmtime.

Signed-off-by: Tyler Rockwood <[email protected]>

* c-api: don't reorder headers

The order here matters

Signed-off-by: Tyler Rockwood <[email protected]>

* c-api: apply clang-format

Signed-off-by: Tyler Rockwood <[email protected]>

* fiber: apply clang-format

Signed-off-by: Tyler Rockwood <[email protected]>

* runtime: apply clang-format

Signed-off-by: Tyler Rockwood <[email protected]>

* examples: apply clang format

Signed-off-by: Tyler Rockwood <[email protected]>

* tests: apply clang-format

Signed-off-by: Tyler Rockwood <[email protected]>

* ci: add clang-format checks

Signed-off-by: Tyler Rockwood <[email protected]>

* clang-format: keep braces on the same line

This is more the existing style

Signed-off-by: Tyler Rockwood <[email protected]>

* remove clang-format

Just use the tool defaults (LLVM)

Signed-off-by: Tyler Rockwood <[email protected]>

* Fix ci name

Signed-off-by: Tyler Rockwood <[email protected]>

* manually reformat a couple of comments

prtest:full

Signed-off-by: Tyler Rockwood <[email protected]>

* disable formatting for doc-wasm.h

Signed-off-by: Tyler Rockwood <[email protected]>

* manually reformat wasmtime.h

Signed-off-by: Tyler Rockwood <[email protected]>

* disable formatting

To prevent a link from being broken

Signed-off-by: Tyler Rockwood <[email protected]>

* examples: fixing build commands

Signed-off-by: Tyler Rockwood <[email protected]>

* fix parameter comment

Signed-off-by: Tyler Rockwood <[email protected]>

---------

Signed-off-by: Tyler Rockwood <[email protected]>

show more ...


Revision tags: v15.0.0, v14.0.4, v14.0.3, v14.0.2, v13.0.1, v14.0.1, v14.0.0, minimum-viable-wasi-proxy-serve, v13.0.0, v12.0.2, v11.0.2, v10.0.2, v12.0.1, v12.0.0, v11.0.1, v11.0.0, v10.0.1, v10.0.0, v9.0.4, v9.0.3, v9.0.2, v9.0.1, v9.0.0, v6.0.2, v7.0.1, v8.0.1, v8.0.0, v7.0.0, v6.0.1, v5.0.1, v4.0.1, v6.0.0, v5.0.0, v4.0.0, v3.0.1, v3.0.0, v1.0.2, v2.0.2, v2.0.1, v2.0.0, v1.0.1, v1.0.0, v0.40.1, v0.40.0
# 2ba3025e 22-Jul-2022 TheGreatRambler <[email protected]>

Add cmake compatibility to c-api (#4369)

* Add cmake compatibility to c-api

* Add CMake documentation to wasmtime.h

* Add CMake instructions in examples

* Modify CI for CMake support

* U

Add cmake compatibility to c-api (#4369)

* Add cmake compatibility to c-api

* Add CMake documentation to wasmtime.h

* Add CMake instructions in examples

* Modify CI for CMake support

* Use correct rust in CI

* Trigger build

* Refactor run-examples

* Reintroduce example_to_run in run-examples

* Replace run-examples crate with cmake

* Fix markdown formatting in examples readme

* Fix cmake test quotes

* Build rust wasm before cmake tests

* Pass CTEST_OUTPUT_ON_FAILURE

* Another cmake test

* Handle os differences in cmake test

* Fix bugs in memory and multimemory examples

show more ...


Revision tags: v0.39.1, v0.38.3, v0.38.2, v0.39.0, v0.38.1, v0.38.0, v0.37.0, v0.36.0, v0.35.3, v0.34.2, v0.35.2, v0.35.1, v0.35.0, v0.33.1, v0.34.1, v0.34.0, v0.33.0, v0.32.1, v0.32.0, v0.31.0, v0.30.0, v0.29.0, v0.28.0
# 7a1b7cdf 03-Jun-2021 Alex Crichton <[email protected]>

Implement RFC 11: Redesigning Wasmtime's APIs (#2897)

Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more inform

Implement RFC 11: Redesigning Wasmtime's APIs (#2897)

Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.

show more ...


Revision tags: v0.26.1, v0.27.0, v0.26.0, v0.25.0, v0.24.0, v0.23.0, v0.22.1
# f94db655 14-Jan-2021 Peter Huene <[email protected]>

Update WebAssembly C API submodule to latest commit. (#2579)

* Update WebAssembly C API submodule to latest commit.

This commit updates the WebAssembly C API submodule (for `wasm.h`) to the
late

Update WebAssembly C API submodule to latest commit. (#2579)

* Update WebAssembly C API submodule to latest commit.

This commit updates the WebAssembly C API submodule (for `wasm.h`) to the
latest commit out of master.

This fixes the behavior of `wasm_name_new_from_string` such that it no longer
copies the null character into the name, which caused unexpected failures when
using the Wasmtime linker as imports wouldn't resolve when the null was
present.

Along with this change were breaking changes to `wasm_func_call`, the host
callback signatures, and `wasm_instance_new` to take a vector type instead of a
pointer to an unsized array.

As a result, Wasmtime language bindings based on the C API will need to be
updated once this change is pulled in.

Fixes #2211.
Fixes #2131.

* Update Doxygen comments for wasm.h changes.

show more ...


Revision tags: cranelift-v0.69.0, v0.22.0, v0.21.0, v0.20.0
# eb650f6f 29-Sep-2020 Joshua Warner <[email protected]>

filesystem example (#2236)


# 56c517d2 21-Jul-2020 Nick Fitzgerald <[email protected]>

examples: Add a GC call to the externref C example


Revision tags: v0.19.0
# a817470f 15-Jul-2020 Yury Delendik <[email protected]>

Fix signature of wasmtime_module_new


# 89603bc6 10-Jul-2020 Nick Fitzgerald <[email protected]>

wasmtime-c-api: Make `wasm_table_set` *not* take ownership of its reference

Same for `wasm_table_grow` and `wasm_table_new` and their `init` values.


# b73b2e0d 10-Jul-2020 Nick Fitzgerald <[email protected]>

wasmtime-c-api: Make `wasmtime_externref_new` write to an out pointer

The C API prefers not to return structs by value.

Same for `wasmtime_externref_new_with_finalizer`.


# 4a349ee2 08-Jul-2020 Nick Fitzgerald <[email protected]>

wasmtime: Add `externref` Rust example


# 5ed8a9ba 08-Jul-2020 Nick Fitzgerald <[email protected]>

wasmtime-c-api: Add an `externref`s example for the C API