Skip to content

Commit 7d66eb5

Browse files
catenacybervictorjulien
authored andcommitted
rust: remove unused function
rust_string_to_c was used when a buffer should be used as it could contain nul-byte
1 parent 9b12fd9 commit 7d66eb5

1 file changed

Lines changed: 0 additions & 28 deletions

File tree

rust/src/common.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
//! Utility library module for commonly used strings, hexadecimals and other elements.
1919
2020
use crate::jsonbuilder::HEX;
21-
use std::ffi::CString;
22-
use std::os::raw::c_char;
2321

2422
pub mod nom7 {
2523
use nom7::bytes::streaming::{tag, take_until};
@@ -101,32 +99,6 @@ pub mod nom8 {
10199
}
102100
}
103101

104-
/// Convert a String to C-compatible string
105-
///
106-
/// This function will consume the provided data and use the underlying bytes to construct a new
107-
/// string, ensuring that there is a trailing 0 byte. This trailing 0 byte will be appended by this
108-
/// function; the provided data should *not* contain any 0 bytes in it.
109-
///
110-
/// Returns a valid pointer, or NULL
111-
pub fn rust_string_to_c(s: String) -> *mut c_char {
112-
CString::new(s)
113-
.map(|c_str| c_str.into_raw())
114-
.unwrap_or(std::ptr::null_mut())
115-
}
116-
117-
/// Free a CString allocated by Rust (for ex. using `rust_string_to_c`)
118-
///
119-
/// # Safety
120-
///
121-
/// s must be allocated by rust, using `CString::new`
122-
#[no_mangle]
123-
pub unsafe extern "C" fn SCRustCStringFree(s: *mut c_char) {
124-
if s.is_null() {
125-
return;
126-
}
127-
drop(CString::from_raw(s));
128-
}
129-
130102
/// Convert an u8-array of data into a hexadecimal representation
131103
pub fn to_hex(input: &[u8]) -> String {
132104
return input

0 commit comments

Comments
 (0)