From ea321b7f13e59120a9995284ee0d1f9c7498c06b Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Wed, 23 Apr 2025 23:47:39 -0400 Subject: [PATCH] fix(wasm): use wee_alloc instead of stdlib malloc Signed-off-by: Xe Iaso --- Cargo.lock | 51 +++++++++++++++++++++++++++++++++++++++++- wasm/anubis/Cargo.toml | 1 + wasm/anubis/src/lib.rs | 5 +++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 11d059ff..abf1af25 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" @@ -59,6 +62,12 @@ dependencies = [ "hybrid-array", ] +[[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" @@ -146,6 +155,12 @@ version = "0.2.171" 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" @@ -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 30f1747a..e55fb21d 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 28994ecd..710492fb 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};