aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-04-23 23:47:39 -0400
committerXe Iaso <me@xeiaso.net>2025-04-23 23:47:49 -0400
commitea321b7f13e59120a9995284ee0d1f9c7498c06b (patch)
tree222c4a3a64cfd23030db7c0d0d704927c3ab563f
parent1c4f2d1851c3b895c3d69be25aac43fd6984449a (diff)
downloadanubis-ea321b7f13e59120a9995284ee0d1f9c7498c06b.tar.xz
anubis-ea321b7f13e59120a9995284ee0d1f9c7498c06b.zip
fix(wasm): use wee_alloc instead of stdlib malloc
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--Cargo.lock51
-rw-r--r--wasm/anubis/Cargo.toml1
-rw-r--r--wasm/anubis/src/lib.rs5
3 files changed, 56 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 11d059f..abf1af2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5,6 +5,9 @@ version = 4
[[package]]
name = "anubis"
version = "0.1.0"
+dependencies = [
+ "wee_alloc",
+]
[[package]]
name = "argon2"
@@ -61,6 +64,12 @@ dependencies = [
[[package]]
name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
+[[package]]
+name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
@@ -147,6 +156,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
+name = "memory_units"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
+
+[[package]]
name = "password-hash"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -169,7 +184,7 @@ version = "0.11.0-pre.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b4241d1a56954dce82cecda5c8e9c794eef6f53abe5e5216bac0a0ea71ffa7"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
"cpufeatures",
"digest 0.11.0-pre.10",
]
@@ -199,3 +214,37 @@ name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "wee_alloc"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
+dependencies = [
+ "cfg-if 0.1.10",
+ "libc",
+ "memory_units",
+ "winapi",
+]
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/wasm/anubis/Cargo.toml b/wasm/anubis/Cargo.toml
index 30f1747..e55fb21 100644
--- a/wasm/anubis/Cargo.toml
+++ b/wasm/anubis/Cargo.toml
@@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2024"
[dependencies]
+wee_alloc = "0.4"
diff --git a/wasm/anubis/src/lib.rs b/wasm/anubis/src/lib.rs
index 28994ec..710492f 100644
--- a/wasm/anubis/src/lib.rs
+++ b/wasm/anubis/src/lib.rs
@@ -1,5 +1,10 @@
use std::sync::{LazyLock, Mutex};
+extern crate wee_alloc;
+
+#[global_allocator]
+static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
+
#[cfg(target_arch = "wasm32")]
mod hostimport {
use crate::{DATA_BUFFER, DATA_LENGTH};