summaryrefslogtreecommitdiff
path: root/rust/src/medium_level_il
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-04 19:10:56 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commita826c589dfc10c542deba7ca3343a462e02d6bde (patch)
treef116254bef39f787268bbecc5eac19da310db9ce /rust/src/medium_level_il
parent28b3c4044af06fdc32c9c85bf8381b5058306427 (diff)
[Rust] Simplify `BnStrCompatible` trait
Followup to https://github.com/Vector35/binaryninja-api/pull/5897/ This simplifies usage of the trait in user code, should just be able to `to_cstr` to get the cstr repr and then call `as_ptr`. Co-authored-by: Michael Krasnitski <michael.krasnitski@gmail.com>
Diffstat (limited to 'rust/src/medium_level_il')
-rw-r--r--rust/src/medium_level_il/function.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/rust/src/medium_level_il/function.rs b/rust/src/medium_level_il/function.rs
index 0ac82ff1..de3ece02 100644
--- a/rust/src/medium_level_il/function.rs
+++ b/rust/src/medium_level_il/function.rs
@@ -11,7 +11,7 @@ use crate::disassembly::DisassemblySettings;
use crate::flowgraph::FlowGraph;
use crate::function::{Function, Location};
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Ref, RefCountable};
-use crate::string::BnStrCompatible;
+use crate::string::AsCStr;
use crate::types::Type;
use crate::variable::{PossibleValueSet, RegisterValue, SSAVariable, UserVariableValue, Variable};
@@ -122,14 +122,14 @@ impl MediumLevelILFunction {
unsafe { Array::new(raw_instr_idxs, count, self.to_owned()) }
}
- pub fn create_user_stack_var<'a, S: BnStrCompatible, C: Into<Conf<&'a Type>>>(
+ pub fn create_user_stack_var<'a, S: AsCStr, C: Into<Conf<&'a Type>>>(
self,
offset: i64,
var_type: C,
name: S,
) {
let mut owned_raw_var_ty = Conf::<&Type>::into_raw(var_type.into());
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
unsafe {
BNCreateUserStackVariable(
self.function().handle,
@@ -144,7 +144,7 @@ impl MediumLevelILFunction {
unsafe { BNDeleteUserStackVariable(self.function().handle, offset) }
}
- pub fn create_user_var<'a, S: BnStrCompatible, C: Into<Conf<&'a Type>>>(
+ pub fn create_user_var<'a, S: AsCStr, C: Into<Conf<&'a Type>>>(
&self,
var: &Variable,
var_type: C,
@@ -153,7 +153,7 @@ impl MediumLevelILFunction {
) {
let raw_var = BNVariable::from(var);
let mut owned_raw_var_ty = Conf::<&Type>::into_raw(var_type.into());
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
unsafe {
BNCreateUserVariable(
self.function().handle,
@@ -274,14 +274,14 @@ impl MediumLevelILFunction {
Ok(())
}
- pub fn create_auto_stack_var<'a, T: Into<Conf<&'a Type>>, S: BnStrCompatible>(
+ pub fn create_auto_stack_var<'a, T: Into<Conf<&'a Type>>, S: AsCStr>(
&self,
offset: i64,
var_type: T,
name: S,
) {
let mut owned_raw_var_ty = Conf::<&Type>::into_raw(var_type.into());
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
let name_c_str = name.as_ref();
unsafe {
BNCreateAutoStackVariable(
@@ -297,7 +297,7 @@ impl MediumLevelILFunction {
unsafe { BNDeleteAutoStackVariable(self.function().handle, offset) }
}
- pub fn create_auto_var<'a, S: BnStrCompatible, C: Into<Conf<&'a Type>>>(
+ pub fn create_auto_var<'a, S: AsCStr, C: Into<Conf<&'a Type>>>(
&self,
var: &Variable,
var_type: C,
@@ -306,7 +306,7 @@ impl MediumLevelILFunction {
) {
let raw_var = BNVariable::from(var);
let mut owned_raw_var_ty = Conf::<&Type>::into_raw(var_type.into());
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
let name_c_str = name.as_ref();
unsafe {
BNCreateAutoVariable(