|
4 | 4 | //! Provides 13 initialization functions with 100% backward compatibility. |
5 | 5 |
|
6 | 6 | use lazy_static::lazy_static; |
7 | | -use std::ffi::{c_char, CStr}; |
| 7 | +use std::ffi::{c_char, c_int, CStr}; |
8 | 8 | use std::path::Path; |
9 | 9 | use std::sync::{Arc, Mutex}; |
10 | 10 |
|
@@ -375,11 +375,11 @@ pub extern "C" fn init_unified_classifier_c( |
375 | 375 | pii_head_path: *const c_char, |
376 | 376 | security_head_path: *const c_char, |
377 | 377 | intent_labels: *const *const c_char, |
378 | | - intent_labels_count: usize, |
| 378 | + intent_labels_count: c_int, |
379 | 379 | pii_labels: *const *const c_char, |
380 | | - pii_labels_count: usize, |
| 380 | + pii_labels_count: c_int, |
381 | 381 | security_labels: *const *const c_char, |
382 | | - security_labels_count: usize, |
| 382 | + security_labels_count: c_int, |
383 | 383 | _use_cpu: bool, |
384 | 384 | ) -> bool { |
385 | 385 | // Adapted from lib.rs:1180-1266 |
@@ -413,21 +413,21 @@ pub extern "C" fn init_unified_classifier_c( |
413 | 413 |
|
414 | 414 | // Convert C string arrays to Rust Vec<String> |
415 | 415 | 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) |
417 | 417 | .iter() |
418 | 418 | .map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string()) |
419 | 419 | .collect::<Vec<String>>() |
420 | 420 | }; |
421 | 421 |
|
422 | 422 | 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) |
424 | 424 | .iter() |
425 | 425 | .map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string()) |
426 | 426 | .collect::<Vec<String>>() |
427 | 427 | }; |
428 | 428 |
|
429 | 429 | 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) |
431 | 431 | .iter() |
432 | 432 | .map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string()) |
433 | 433 | .collect::<Vec<String>>() |
|
0 commit comments