use ref instead of unsafe pointer stuff

This commit is contained in:
Doug MacEachern 2004-09-22 17:48:21 +00:00
parent ab39e15dbe
commit 6c7fccda29
2 changed files with 3 additions and 6 deletions

View File

@ -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"/>

View File

@ -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);
} }