diff options
| author | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2026-07-19 20:14:13 +0500 |
|---|---|---|
| committer | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2026-07-19 20:14:13 +0500 |
| commit | 07fbf865fe5f4a8f6f352c5419bbccccc99eb336 (patch) | |
| tree | a499c8ce96ef069044df24792295389bc1116184 /script | |
| parent | b3ea7a0ffcc24a3363d6fb507812438fe0d1ff16 (diff) | |
js init
Diffstat (limited to 'script')
| -rw-r--r-- | script/Makefile | 2 | ||||
| -rw-r--r-- | script/entry.c | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/script/Makefile b/script/Makefile new file mode 100644 index 0000000..2e24e90 --- /dev/null +++ b/script/Makefile @@ -0,0 +1,2 @@ +all: + emcc entry.c -sEXPORTED_FUNCTIONS="_entry,_allocate,_deallocate" -o ../mod.wasm --no-entry diff --git a/script/entry.c b/script/entry.c new file mode 100644 index 0000000..a8f3b68 --- /dev/null +++ b/script/entry.c @@ -0,0 +1,16 @@ +#include <stdlib.h> +#include <string.h> + +void* allocate(size_t size) { + return malloc(size); +} + +// Expose free so JS can clean up memory and prevent leaks +void deallocate(void* ptr) { + free(ptr); +} + + +const char *entry(const char *input) { + return strdup(input); +} |
