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

[DRAFT] Tried to add direct calls example, but init fails #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iliakan
Copy link

@iliakan iliakan commented Feb 5, 2023

The natural thing for wasm is to call functions from JS directly or using cwrap, but I failed to do so.

In short, this fails:

let repoPointer = Module._malloc(8);

// int git_repository_init(git_repository **out, const char *path, unsigned int is_bare);
let git_repository_init = Module.cwrap('git_repository_init', 'number', ['number','string','number']); 

let r1 = git_repository_init(repoPointer, "/working", 0); // -1 (failed)

I tracked the problem inside libgit2.

The root of the issue is here: https://github.com/libgit2/libgit2/blob/main/src/util/str.c#L86

This grealloc call (which appears to use the stdalloc realloc) doesn't work, new_ptr becomes 0.
May it be connected with some memory issues? Or did I screw up somewhere? ;)

This PR contains a few changes I made to use git_repository_init.
Not intended for merging. Once I figure out the problem, I'll be able to submit a better variant.

@iliakan iliakan mentioned this pull request Feb 5, 2023
@iliakan iliakan changed the title Tried to add direct calls example, but init fails [DRAFT] Tried to add direct calls example, but init fails Feb 5, 2023
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.

1 participant