Skip to content

Commit 726da88

Browse files
committed
Remove some libc dependencies.
For `c2rust-ast-exporter` the `std::ffi` equivalents can be used instead.
1 parent 71c95a2 commit 726da88

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

c2rust-ast-exporter/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ categories.workspace = true
1313
links = "clangAstExporter"
1414

1515
[dependencies]
16-
libc = "0.2"
1716
serde = "1.0"
1817
serde_bytes = "0.11"
1918
serde_cbor = "0.11"

c2rust-ast-exporter/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde_cbor::{from_slice, Value};
22
use std::collections::HashMap;
3-
use std::ffi::{CStr, CString};
3+
use std::ffi::{c_char, c_int, CStr, CString};
44
use std::io::{Error, ErrorKind};
55
use std::path::Path;
66
use std::slice;
@@ -60,12 +60,12 @@ fn get_ast_cbors(
6060
args_owned.push(CString::new(["-extra-arg=", arg].join("")).unwrap())
6161
}
6262

63-
let args_ptrs: Vec<*const libc::c_char> = args_owned.iter().map(|x| x.as_ptr()).collect();
63+
let args_ptrs: Vec<*const c_char> = args_owned.iter().map(|x| x.as_ptr()).collect();
6464

6565
let hashmap;
6666
unsafe {
6767
let ptr = ast_exporter(
68-
args_ptrs.len() as libc::c_int,
68+
args_ptrs.len() as c_int,
6969
args_ptrs.as_ptr(),
7070
debug.into(),
7171
&mut res,
@@ -86,16 +86,16 @@ mod ffi {
8686
extern "C" {
8787
// ExportResult *ast_exporter(int argc, char *argv[]);
8888
fn ast_exporter(
89-
argc: libc::c_int,
90-
argv: *const *const libc::c_char,
91-
debug: libc::c_int,
92-
res: *mut libc::c_int,
89+
argc: c_int,
90+
argv: *const *const c_char,
91+
debug: c_int,
92+
res: *mut c_int,
9393
) -> *mut ffi::ExportResult;
9494

9595
// void drop_export_result(ExportResult *result);
9696
fn drop_export_result(ptr: *mut ffi::ExportResult);
9797

98-
fn clang_version() -> *const libc::c_char;
98+
fn clang_version() -> *const c_char;
9999
}
100100

101101
unsafe fn marshal_result(result: *const ffi::ExportResult) -> HashMap<String, Vec<u8>> {

0 commit comments

Comments
 (0)