use ref instead of unsafe pointer stuff
This commit is contained in:
parent
ab39e15dbe
commit
6c7fccda29
|
@ -25,7 +25,6 @@
|
||||||
<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>
|
||||||
<include name="src/Sigar.cs"/>
|
<include name="src/Sigar.cs"/>
|
||||||
|
|
|
@ -34,16 +34,14 @@ namespace Hyperic.Sigar {
|
||||||
internal HandleRef sigar;
|
internal HandleRef sigar;
|
||||||
|
|
||||||
[DllImport(LIBSIGAR)]
|
[DllImport(LIBSIGAR)]
|
||||||
unsafe private static extern int sigar_open(IntPtr *sigar);
|
private static extern int sigar_open(ref 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;
|
IntPtr handle = IntPtr.Zero;
|
||||||
unsafe { //&pointers are considered "unsafe"
|
sigar_open(ref handle);
|
||||||
sigar_open(&handle);
|
|
||||||
}
|
|
||||||
this.sigar = new HandleRef(this, handle);
|
this.sigar = new HandleRef(this, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue