Skip to content

Commit 2e139f7

Browse files
carloryrootfs
authored andcommitted
Change label count params to c_int (vllm-project#494)
Signed-off-by: carlory <[email protected]>
1 parent aeecbea commit 2e139f7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

candle-binding/src/ffi/init.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! Provides 13 initialization functions with 100% backward compatibility.
55
66
use lazy_static::lazy_static;
7-
use std::ffi::{c_char, CStr};
7+
use std::ffi::{c_char, c_int, CStr};
88
use std::path::Path;
99
use std::sync::{Arc, Mutex};
1010

@@ -375,11 +375,11 @@ pub extern "C" fn init_unified_classifier_c(
375375
pii_head_path: *const c_char,
376376
security_head_path: *const c_char,
377377
intent_labels: *const *const c_char,
378-
intent_labels_count: usize,
378+
intent_labels_count: c_int,
379379
pii_labels: *const *const c_char,
380-
pii_labels_count: usize,
380+
pii_labels_count: c_int,
381381
security_labels: *const *const c_char,
382-
security_labels_count: usize,
382+
security_labels_count: c_int,
383383
_use_cpu: bool,
384384
) -> bool {
385385
// Adapted from lib.rs:1180-1266
@@ -413,21 +413,21 @@ pub extern "C" fn init_unified_classifier_c(
413413

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

422422
let _pii_labels_vec = unsafe {
423-
std::slice::from_raw_parts(pii_labels, pii_labels_count)
423+
std::slice::from_raw_parts(pii_labels, pii_labels_count as usize)
424424
.iter()
425425
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
426426
.collect::<Vec<String>>()
427427
};
428428

429429
let _security_labels_vec = unsafe {
430-
std::slice::from_raw_parts(security_labels, security_labels_count)
430+
std::slice::from_raw_parts(security_labels, security_labels_count as usize)
431431
.iter()
432432
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
433433
.collect::<Vec<String>>()

0 commit comments

Comments
 (0)