From 788a8b7091bbdde77817030e0836d7a7a786fd99 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 19:47:55 -0400 Subject: [Rust] Simplify usage surrounding c strings `cstring.as_ref().as_ptr() as *const c_char` -> `cstring.as_ptr()` `cstring.as_ref().as_ptr() as *mut _` -> `cstring.as_ptr()` `cstring.as_ptr() as *const c_char` -> `cstring.as_ptr()` With a few fixes for cstrings that might be dropped prematurely. --- rust/src/worker_thread.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'rust/src/worker_thread.rs') diff --git a/rust/src/worker_thread.rs b/rust/src/worker_thread.rs index aed872de..e0d7b0db 100644 --- a/rust/src/worker_thread.rs +++ b/rust/src/worker_thread.rs @@ -1,6 +1,6 @@ use crate::string::AsCStr; use binaryninjacore_sys::*; -use std::ffi::{c_char, c_void}; +use std::ffi::c_void; pub struct WorkerThreadActionExecutor { func: Box, @@ -25,7 +25,7 @@ pub fn execute_on_worker_thread(name: S, f: F) { BNWorkerEnqueueNamed( raw_executor as *mut c_void, Some(WorkerThreadActionExecutor::cb_execute), - name.as_ref().as_ptr() as *const c_char, + name.as_ptr(), ) } } @@ -38,7 +38,7 @@ pub fn execute_on_worker_thread_priority(name: S, BNWorkerPriorityEnqueueNamed( raw_executor as *mut c_void, Some(WorkerThreadActionExecutor::cb_execute), - name.as_ref().as_ptr() as *const c_char, + name.as_ptr(), ) } } @@ -51,7 +51,7 @@ pub fn execute_on_worker_thread_interactive(name: BNWorkerInteractiveEnqueueNamed( raw_executor as *mut c_void, Some(WorkerThreadActionExecutor::cb_execute), - name.as_ref().as_ptr() as *const c_char, + name.as_ptr(), ) } } -- cgit v1.3.1