Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions candle-binding/src/ffi/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Provides 13 initialization functions with 100% backward compatibility.

use lazy_static::lazy_static;
use std::ffi::{c_char, CStr};
use std::ffi::{c_char, c_int, CStr};
use std::path::Path;
use std::sync::{Arc, Mutex};

Expand Down Expand Up @@ -375,11 +375,11 @@ pub extern "C" fn init_unified_classifier_c(
pii_head_path: *const c_char,
security_head_path: *const c_char,
intent_labels: *const *const c_char,
intent_labels_count: usize,
intent_labels_count: c_int,
pii_labels: *const *const c_char,
pii_labels_count: usize,
pii_labels_count: c_int,
security_labels: *const *const c_char,
security_labels_count: usize,
security_labels_count: c_int,
_use_cpu: bool,
) -> bool {
// Adapted from lib.rs:1180-1266
Expand Down Expand Up @@ -413,21 +413,21 @@ pub extern "C" fn init_unified_classifier_c(

// Convert C string arrays to Rust Vec<String>
let _intent_labels_vec = unsafe {
std::slice::from_raw_parts(intent_labels, intent_labels_count)
std::slice::from_raw_parts(intent_labels, intent_labels_count as usize)
.iter()
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
.collect::<Vec<String>>()
};

let _pii_labels_vec = unsafe {
std::slice::from_raw_parts(pii_labels, pii_labels_count)
std::slice::from_raw_parts(pii_labels, pii_labels_count as usize)
.iter()
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
.collect::<Vec<String>>()
};

let _security_labels_vec = unsafe {
std::slice::from_raw_parts(security_labels, security_labels_count)
std::slice::from_raw_parts(security_labels, security_labels_count as usize)
.iter()
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
.collect::<Vec<String>>()
Expand Down
Loading