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