pub mod database;
pub mod error;
pub mod scanner;
pub mod scratch;
pub use crate::vectorscan::scanner::VectorscanScanner;
#[cfg(target_os = "macos")]
use std::ffi::c_void;
#[cfg(target_os = "macos")]
use std::sync::Once;
#[cfg(target_os = "macos")]
use vectorscan_rs_sys as hs;
#[cfg(target_os = "macos")]
unsafe extern "C" {
fn mi_malloc(size: usize) -> *mut c_void;
fn mi_free(ptr: *mut c_void);
}
#[cfg(target_os = "macos")]
static INIT_ALLOCATOR: Once = Once::new();
#[cfg(target_os = "macos")]
pub(crate) fn init_allocator() {
INIT_ALLOCATOR.call_once(|| unsafe {
let status = hs::hs_set_allocator(Some(mi_malloc), Some(mi_free));
assert_eq!(
status,
hs::HS_SUCCESS as hs::hs_error_t,
"failed to set vectorscan allocator to mimalloc"
);
});
}