1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::function::FunctionCallback;
use crate::support::intptr_t;
use std::ffi::c_void;
pub struct ExternalReferences {
null_terminated: Vec<*const libc::c_void>,
}
unsafe impl Sync for ExternalReferences {}
impl ExternalReferences {
pub fn new(refs: &[FunctionCallback]) -> Self {
let mut null_terminated = Vec::with_capacity(refs.len() + 1);
for r in refs {
null_terminated.push(*r as *const c_void);
}
null_terminated.push(std::ptr::null());
Self { null_terminated }
}
pub fn as_ptr(&self) -> *const intptr_t {
self.null_terminated.as_ptr() as *const intptr_t
}
}