From d19f5e85ee26c3d6604798d30ab821d15731cada Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Wed, 19 May 2021 20:40:24 -0400 Subject: DebugInfo - plugable debug information importers - C++, Rust, and Python APIs --- rust/src/string.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'rust/src/string.rs') diff --git a/rust/src/string.rs b/rust/src/string.rs index e042dbdd..198c764b 100644 --- a/rust/src/string.rs +++ b/rust/src/string.rs @@ -21,6 +21,14 @@ use std::os::raw; use crate::rc::*; +pub(crate) fn raw_to_string(ptr: *const raw::c_char) -> Option { + if ptr.is_null() { + None + } else { + Some(unsafe { CStr::from_ptr(ptr).to_string_lossy().into_owned() }) + } +} + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[repr(C)] pub struct BnStr { -- cgit v1.3.1