use sigar_open instead of sigar_new wrapper
This commit is contained in:
parent
a301251699
commit
bcd94bb327
|
@ -25,6 +25,7 @@
|
||||||
<mkdir dir="${build.dir}"/>
|
<mkdir dir="${build.dir}"/>
|
||||||
|
|
||||||
<csc target="library" debug="${debug}"
|
<csc target="library" debug="${debug}"
|
||||||
|
unsafe="true"
|
||||||
output="${sigarsharp}">
|
output="${sigarsharp}">
|
||||||
<sources>
|
<sources>
|
||||||
<includes name="src/Sigar.cs"/>
|
<includes name="src/Sigar.cs"/>
|
||||||
|
|
|
@ -31,13 +31,16 @@ namespace Hyperic.Sigar {
|
||||||
internal HandleRef sigar;
|
internal HandleRef sigar;
|
||||||
|
|
||||||
[DllImport(LIBSIGAR)]
|
[DllImport(LIBSIGAR)]
|
||||||
private static extern IntPtr sigar_new();
|
unsafe private static extern int sigar_open(IntPtr *sigar);
|
||||||
|
|
||||||
[DllImport(LIBSIGAR)]
|
[DllImport(LIBSIGAR)]
|
||||||
private static extern int sigar_close(IntPtr sigar);
|
private static extern int sigar_close(IntPtr sigar);
|
||||||
|
|
||||||
public Sigar() {
|
public Sigar() {
|
||||||
IntPtr handle = sigar_new();
|
IntPtr handle;
|
||||||
|
unsafe { //&pointers are considered "unsafe"
|
||||||
|
sigar_open(&handle);
|
||||||
|
}
|
||||||
this.sigar = new HandleRef(this, handle);
|
this.sigar = new HandleRef(this, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue