Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove libc crate dependency, use raw extern C declaration for dlsym

Amrithesh Kakkoth Ente5b4b85212598
diff --git a/mobile/apps/photos/rust/Cargo.lock b/mobile/apps/photos/rust/Cargo.lock
index ff0dad92db..109668feee 100644
--- a/mobile/apps/photos/rust/Cargo.lock
+++ b/mobile/apps/photos/rust/Cargo.lock
@@ -649,7 +649,6 @@ dependencies = [
"image",
"imageproc",
"kamadak-exif",
- "libc",
"libheic-rs",
"nalgebra 0.33.2",
"ndarray 0.16.1",
diff --git a/mobile/apps/photos/rust/Cargo.toml b/mobile/apps/photos/rust/Cargo.toml
index 616a8eee47..5ccaa13bac 100644
--- a/mobile/apps/photos/rust/Cargo.toml
+++ b/mobile/apps/photos/rust/Cargo.toml
@@ -22,7 +22,6 @@ ndarray = "0.16.1"
half = "2.1"
once_cell = "1.20.2"
thiserror = "2.0.11"
-libc = "0.2"
[target.'cfg(target_os = "ios")'.dependencies]
ort = { version = "=2.0.0-rc.4", default-features = false, features = [
diff --git a/mobile/apps/photos/rust/src/ml/runtime.rs b/mobile/apps/photos/rust/src/ml/runtime.rs
index 4a2e09b869..10b26d6801 100644
--- a/mobile/apps/photos/rust/src/ml/runtime.rs
+++ b/mobile/apps/photos/rust/src/ml/runtime.rs
@@ -106,8 +106,14 @@ impl LazySession {
self.session = None;
#[cfg(target_os = "android")]
unsafe {
+ unsafe extern "C" {
+ unsafe fn dlsym(
+ handle: *mut core::ffi::c_void,
+ symbol: *const core::ffi::c_char,
+ ) -> *mut core::ffi::c_void;
+ }
let name = b"malloc_trim\0";
- let sym = libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr().cast());
+ let sym = dlsym(core::ptr::null_mut(), name.as_ptr().cast());
if !sym.is_null() {
let f: unsafe extern "C" fn(usize) -> i32 = core::mem::transmute(sym);
f(0);