Skip to content

Commit

Permalink
fix(c_functions): correct ManuallyDrop scope
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneshorner authored and vhyrro committed May 16, 2023
1 parent a51954c commit 9c289c3
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/c_functions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
ffi::{c_char, CString},
ffi::{c_char, CStr},
mem::ManuallyDrop,
path::PathBuf,
};
Expand Down Expand Up @@ -27,16 +27,14 @@ pub unsafe extern "C" fn parse_file_list(

let file_list = ManuallyDrop::new(Box::from_raw(file_list));

let files = ManuallyDrop::new(
Vec::from_raw_parts(
file_list.data as *mut *mut c_char,
file_list.length,
file_list._capacity,
)
.into_iter()
.map(|str| CString::from_raw(str).to_string_lossy().into_owned().into())
.collect::<Vec<PathBuf>>(),
);
let files = ManuallyDrop::new(Vec::from_raw_parts(
file_list.data as *mut *const c_char,
file_list.length,
file_list._capacity,
))
.iter()
.map(|str| CStr::from_ptr(*str).to_string_lossy().into_owned().into())
.collect::<Vec<PathBuf>>();

let language = tree_sitter::Language::from_raw(language);

Expand Down

0 comments on commit 9c289c3

Please sign in to comment.