Skip to content

Commit

Permalink
Inline cstring retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 authored and tmfink committed Apr 30, 2022
1 parent 175f93f commit 75fb310
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion capstone-rs/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use libc::{self, c_char};
/// - No checks are made for: valid UTF-8
/// - This function "creates" a reference with an arbitrary lifetime, so be careful to limit the
/// lifetime appropriately
#[inline]
pub(crate) unsafe fn str_from_cstr_ptr<'a>(ptr: *const c_char) -> Option<&'a str> {
(!ptr.is_null()).then(|| {
(!ptr.is_null()).then(|| {
let len = libc::strlen(ptr);

/* ASSUMPTION: capstone returns NUL terminated string */
Expand Down

0 comments on commit 75fb310

Please sign in to comment.