diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-03 23:15:17 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 6264254065bbae9d89f51cf3330379b7ace09592 (patch) | |
| tree | 9ece1d1739215c2faef2d808ef4fdc019ad527fa /rust/src/collaboration/sync.rs | |
| parent | c3fdda9727f5507818e3f55576ad32215a22b0f9 (diff) | |
[Rust] Return `String` instead of `BnString` for cases where lossy conversion can be tolerated
Still need to go and audit all usage, but realistically the most important places to give the user control are with symbols, where the data can come from non utf8 sources
This is still incomplete, I just looked for usage of -> BnString so any other variant was omitted.
Diffstat (limited to 'rust/src/collaboration/sync.rs')
| -rw-r--r-- | rust/src/collaboration/sync.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/rust/src/collaboration/sync.rs b/rust/src/collaboration/sync.rs index 1c11b8f0..6fc85d31 100644 --- a/rust/src/collaboration/sync.rs +++ b/rust/src/collaboration/sync.rs @@ -3,7 +3,6 @@ use super::{ }; use binaryninjacore_sys::*; use std::ffi::{c_char, c_void}; -use std::mem::ManuallyDrop; use std::ptr::NonNull; use crate::binary_view::{BinaryView, BinaryViewExt}; @@ -12,7 +11,7 @@ use crate::file_metadata::FileMetadata; use crate::progress::{NoProgressCallback, ProgressCallback}; use crate::project::file::ProjectFile; use crate::rc::Ref; -use crate::string::{BnStrCompatible, BnString}; +use crate::string::{raw_to_string, BnStrCompatible, BnString}; use crate::type_archive::{TypeArchive, TypeArchiveMergeConflict}; // TODO: PathBuf @@ -859,13 +858,11 @@ pub trait DatabaseConflictHandler: Sized { let keys = core::slice::from_raw_parts(keys, conflict_count); let conflicts = core::slice::from_raw_parts(conflicts, conflict_count); keys.iter().zip(conflicts.iter()).all(|(key, conflict)| { - // NOTE this is a reference, not owned, so ManuallyDrop is required, or just implement `ref_from_raw` - // TODO: Replace with raw_to_string - let key = ManuallyDrop::new(BnString::from_raw(*key as *mut _)); + let key = raw_to_string(*key).unwrap(); // TODO I guess dont drop here? let raw_ptr = NonNull::new(*conflict).unwrap(); let conflict = MergeConflict::from_raw(raw_ptr); - ctxt.handle_conflict(key.as_str(), &conflict) + ctxt.handle_conflict(&key, &conflict) }) } } |
