Skip to content

Add context to enlarge memory error callback #2546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

eloparco
Copy link
Contributor

Follow-up on #2522.
When trying to use the callback in practice (from an embedder), I realized that not being able to pass some context (i.e. data passed from the embedder that can be used in the callback) is quite limiting.


/**
* Setup callback invoked when memory.grow fails
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_set_enlarge_mem_error_callback(
const enlarge_memory_error_callback_t callback);
const enlarge_memory_error_callback_t callback, void *context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eloparco How about changing the argument name to user_data? I remember we usually called data like this with user_data.

@eloparco eloparco force-pushed the eloparco/memory-grow-callback-context branch from 07dabc8 to f09a907 Compare September 13, 2023 08:25
@@ -1447,14 +1447,15 @@ typedef enum {
typedef void (*enlarge_memory_error_callback_t)(
uint32_t inc_page_count, uint64_t current_memory_size,
uint32_t memory_index, enlarge_memory_error_reason_t failure_reason,
wasm_module_inst_t instance, wasm_exec_env_t exec_env);
wasm_module_inst_t instance, wasm_exec_env_t exec_env,
void* context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had better void *user_data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed that one, fixed

@eloparco eloparco force-pushed the eloparco/memory-grow-callback-context branch from f09a907 to 01cf290 Compare September 13, 2023 09:26
@wenyongh wenyongh merged commit 83db970 into bytecodealliance:main Sep 13, 2023
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
g0djan pushed a commit to g0djan/wasm-micro-runtime that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants