Skip to content
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

Fix HostFunction with data example #2441

Merged
merged 1 commit into from
Apr 25, 2023
Merged

Fix HostFunction with data example #2441

merged 1 commit into from
Apr 25, 2023

Conversation

rockwotj
Copy link
Contributor

This was broken because it passed in the data in the function pointer parameter and passed in NULL for the data parameter.

This was broken because it passed in the data in the function pointer parameter and passed in `NULL` for the data parameter.

Signed-off-by: Tyler Rockwood <rockwotj@users.noreply.github.com>
@rockwotj rockwotj requested a review from hydai as a code owner April 25, 2023 14:28
Copy link
Member

@hydai hydai left a comment

Choose a reason for hiding this comment

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

Nice catch! Thanks!

@hydai hydai merged commit 4e4d900 into WasmEdge:master Apr 25, 2023
@WasmEdge WasmEdge deleted a comment from alabulei1 Apr 25, 2023
@rockwotj rockwotj deleted the patch-1 branch April 25, 2023 20:28
@juntao
Copy link
Member

juntao commented Apr 26, 2023

flows summarize

Copy link
Member

juntao commented Apr 26, 2023

Hello, I am a code review bot on flows.network. Here are my reviews of code commits in this PR.


Commit 7cc7b35f5e8e5f25fbf85296e330c81b59f694f8

The key change in this patch is the modification of the function call WasmEdge_FunctionInstanceCreate in the "HostFunction with data example" section of the documentation. The author fixed the issue where the data was being passed in the function pointer parameter and NULL was being passed in the data parameter.

Original line:

WasmEdge_FunctionInstanceCreate(HostFType, (void *)(&Number), NULL, 0);

Modified line:

WasmEdge_FunctionInstanceCreate(HostFType, &PrintData, (void *)(&Number), 0);

This change correctly passes the function pointer parameter &PrintData and the data parameter (void *)(&Number) to the WasmEdge_FunctionInstanceCreate function.

There don't appear to be any potential problems with this change, as it's simply fixing an incorrect function call in the provided example by passing the correct parameters.

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.

3 participants