summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-03-13 12:20:27 -0700
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-24 18:46:48 -0700
commitc43ecea6535c12d8b04ca8cede1a35cb9fb66af9 (patch)
tree5b3da92fcf2178b7a7ff8eecf3d3f933a5bf9bf8 /plugins
parenta40a300cce8a798200562e9d4515116360dbd0b1 (diff)
[Rust] Move `ObjectDestructor` to own module and add some extra documentation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/warp/src/cache.rs10
-rw-r--r--plugins/warp/src/plugin/debug.rs2
-rw-r--r--plugins/workflow_objc/src/metadata/global_state.rs7
3 files changed, 8 insertions, 11 deletions
diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs
index 3df2dbf8..d9a5a8d1 100644
--- a/plugins/warp/src/cache.rs
+++ b/plugins/warp/src/cache.rs
@@ -9,18 +9,14 @@ pub use type_reference::*;
use binaryninja::binary_view::{BinaryView, BinaryViewExt};
use binaryninja::function::Function as BNFunction;
+use binaryninja::object_destructor::{register_object_destructor, ObjectDestructor};
use binaryninja::rc::Guard;
use binaryninja::rc::Ref as BNRef;
-use binaryninja::ObjectDestructor;
use std::hash::{DefaultHasher, Hash, Hasher};
pub fn register_cache_destructor() {
- pub static mut CACHE_DESTRUCTOR: CacheDestructor = CacheDestructor;
- #[allow(static_mut_refs)]
- // SAFETY: This can be done as the backing data is an opaque ZST.
- unsafe {
- CACHE_DESTRUCTOR.register()
- };
+ let destructor = register_object_destructor(CacheDestructor);
+ std::mem::forget(destructor);
}
/// A unique view ID, used for caching.
diff --git a/plugins/warp/src/plugin/debug.rs b/plugins/warp/src/plugin/debug.rs
index d220d329..4198ea30 100644
--- a/plugins/warp/src/plugin/debug.rs
+++ b/plugins/warp/src/plugin/debug.rs
@@ -3,7 +3,7 @@ use crate::{build_function, cache};
use binaryninja::binary_view::BinaryView;
use binaryninja::command::{Command, FunctionCommand};
use binaryninja::function::Function;
-use binaryninja::ObjectDestructor;
+use binaryninja::object_destructor::ObjectDestructor;
pub struct DebugFunction;
diff --git a/plugins/workflow_objc/src/metadata/global_state.rs b/plugins/workflow_objc/src/metadata/global_state.rs
index db29af49..6c128e22 100644
--- a/plugins/workflow_objc/src/metadata/global_state.rs
+++ b/plugins/workflow_objc/src/metadata/global_state.rs
@@ -1,11 +1,12 @@
use binaryninja::file_metadata::SessionId;
+use binaryninja::object_destructor::register_object_destructor;
use binaryninja::{
binary_view::{BinaryView, BinaryViewBase, BinaryViewExt},
file_metadata::FileMetadata,
metadata::Metadata,
+ object_destructor::ObjectDestructor,
rc::Ref,
settings::{QueryOptions, Settings},
- ObjectDestructor,
};
use dashmap::DashMap;
use once_cell::sync::Lazy;
@@ -66,8 +67,8 @@ pub struct GlobalState;
impl GlobalState {
pub fn register_cleanup() {
- let observer = Box::leak(Box::new(ObjectLifetimeObserver));
- observer.register();
+ let destructor = register_object_destructor(ObjectLifetimeObserver);
+ std::mem::forget(destructor);
}
fn id(bv: &BinaryView) -> SessionId {