Hi, I’m trying to build complete FFI bindings for Hyperic Sigar.
It does some memory management on it’s own for certain cases, such as lists of CPUs and so on, and unfortunately there are no examples of doing similar things / working with more compelx FFI structures are available (or at least I could find those).
They have a procedure that expects pointer:
SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist);
(here’s a C example for it: https://github.com/hyperic/sigar/blob/master/examples/cpuinfo.c)
Which, if I understand correctly translate to:
#[link(name = "sigar")]
extern {
pub fn sigar_cpu_info_list_get(sigar: *mut sigar_t, cpu_info: *mut sigar_cpu_info_t) -> c_int;
}
As far as I understand, I should create a mutable null pointer and pass it to the fn:
let cpu_info: *mut sigar_cpu_info_t = std::ptr::null_mut();
sigar_cpu_info_list_get(sigar_ptr, cpu_info);
Although that somehow throws an “unknown error”. To be honest, I don’t even know which direction to dig.
Could anyone give a pointer?
Thank you.