[−][src]Function wasmer_runtime_c_api::instance::wasmer_instance_context_data_set
#[no_mangle] pub extern "C" fn wasmer_instance_context_data_set(
instance: *mut wasmer_instance_t,
data_ptr: *mut c_void
)
Sets the data that can be hold by an instance context.
An instance context (represented by the opaque
wasmer_instance_context_t structure) can hold user-defined
data. This function sets the data. This function is complementary
of wasmer_instance_context_data_get().
This function does nothing if instance is a null pointer.
Example:
// Define your own data.
typedef struct {
// …
} my_data;
// Allocate them and set them on the given instance.
my_data *data = malloc(sizeof(my_data));
data->… = …;
wasmer_instance_context_data_set(instance, (void*) my_data);
// You can read your data.
{
my_data *data = (my_data*) wasmer_instance_context_data_get(wasmer_instance_context_get(instance));
// …
}