From 3409ca65d835b858d9cefbe8949552f0f5ad0788 Mon Sep 17 00:00:00 2001 From: Florian Schmiderer Date: Sun, 17 Sep 2023 14:40:22 +0200 Subject: Add OwnedTargetMachine to manage llvm:TargetMachine. Uses pointers instead of &'static mut and provides safe interface to create/dispose it. --- compiler/rustc_data_structures/src/small_c_str.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'compiler/rustc_data_structures') diff --git a/compiler/rustc_data_structures/src/small_c_str.rs b/compiler/rustc_data_structures/src/small_c_str.rs index 719e4e3d974..349fd7f9769 100644 --- a/compiler/rustc_data_structures/src/small_c_str.rs +++ b/compiler/rustc_data_structures/src/small_c_str.rs @@ -79,3 +79,9 @@ impl<'a> FromIterator<&'a str> for SmallCStr { Self { data } } } + +impl From<&ffi::CStr> for SmallCStr { + fn from(s: &ffi::CStr) -> Self { + Self { data: SmallVec::from_slice(s.to_bytes()) } + } +} -- cgit 1.4.1-3-g733a5