We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5b93eae commit f011d11Copy full SHA for f011d11
1 file changed
rustlib_test/src/lib.rs
@@ -0,0 +1,26 @@
1
+#![deny(clippy::all, clippy::pedantic, clippy::nursery, clippy::perf)]
2
+
3
+use std::{ffi::CString, os::raw::c_char};
4
+use std::ptr::null_mut;
5
6
+#[unsafe(no_mangle)]
7
+pub unsafe extern "C" fn greet() {
8
+ println!("Hello World");
9
+}
10
11
12
+pub extern "C" fn get_reim_name() -> *mut c_char {
13
+ CString
14
+ ::new("REIM DEVELOPER")
15
+ .map(|name| name.into_raw())
16
+ .unwrap_or(null_mut())
17
18
19
20
+pub unsafe extern "C" fn free_name(c_string: *mut c_char) {
21
+ if !c_string.is_null() {
22
+ unsafe {
23
+ let _ = CString::from_raw(c_string);
24
+ }
25
26
0 commit comments