summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-07-19 20:14:13 +0500
committerPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-07-19 20:14:13 +0500
commit07fbf865fe5f4a8f6f352c5419bbccccc99eb336 (patch)
treea499c8ce96ef069044df24792295389bc1116184 /script
parentb3ea7a0ffcc24a3363d6fb507812438fe0d1ff16 (diff)
js init
Diffstat (limited to 'script')
-rw-r--r--script/Makefile2
-rw-r--r--script/entry.c16
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);
+}