Function wasmer_c_api::deprecated::instance::wasmer_instance_context_data_set[][src]

#[no_mangle]pub unsafe extern "C" fn wasmer_instance_context_data_set(
    instance: Option<NonNull<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*) data);

// You can read your data.
{
    my_data *data = (my_data*) wasmer_instance_context_data_get(wasmer_instance_context_get(instance));
    // …
}