]> git.lizzy.rs Git - rust.git/commitdiff
Use CString
authorYuki OKUSHI <huyuumi.dev@gmail.com>
Sat, 30 Mar 2019 12:37:02 +0000 (21:37 +0900)
committerYuki OKUSHI <huyuumi.dev@gmail.com>
Sat, 30 Mar 2019 12:37:02 +0000 (21:37 +0900)
src/librustc_codegen_llvm/attributes.rs

index 9aaad60cd6d3c3fba9aadc96b716a22a4bca10bb..77fa34e74dd70cee88a01fbd019a6a1a2bcfe84e 100644 (file)
@@ -80,14 +80,12 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
 
         // The function name varies on platforms.
         // See test/CodeGen/mcount.c in clang.
-        use std::ffi::CStr;
-        let target_mcount = format!("{}{}",
-            &cx.sess().target.target.options.target_mcount, "\0");
-        let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap();
+        let mcount_name = CString::new(
+            cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap();
 
         llvm::AddFunctionAttrStringValue(
             llfn, llvm::AttributePlace::Function,
-            const_cstr!("instrument-function-entry-inlined"), mcount_name);
+            const_cstr!("instrument-function-entry-inlined"), &mcount_name);
     }
 }