mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 01:55:31 +00:00
glib: Use Marshaller methods in Argv for g_malloc and g_free
This commit is contained in:
parent
ced6f5e677
commit
2d48906523
14
glib/Argv.cs
14
glib/Argv.cs
|
@ -30,18 +30,10 @@ namespace GLib {
|
||||||
IntPtr handle;
|
IntPtr handle;
|
||||||
bool add_progname = false;
|
bool add_progname = false;
|
||||||
|
|
||||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern IntPtr g_malloc(IntPtr size);
|
|
||||||
|
|
||||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void g_free (IntPtr mem);
|
|
||||||
|
|
||||||
~Argv ()
|
~Argv ()
|
||||||
{
|
{
|
||||||
foreach (IntPtr arg in arg_ptrs)
|
Marshaller.Free (arg_ptrs);
|
||||||
g_free (arg);
|
Marshaller.Free (handle);
|
||||||
|
|
||||||
g_free (handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Argv (string[] args) : this (args, false) {}
|
public Argv (string[] args) : this (args, false) {}
|
||||||
|
@ -61,7 +53,7 @@ namespace GLib {
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
arg_ptrs [i] = Marshaller.StringToPtrGStrdup (args[i]);
|
arg_ptrs [i] = Marshaller.StringToPtrGStrdup (args[i]);
|
||||||
|
|
||||||
handle = g_malloc (new IntPtr (IntPtr.Size * args.Length));
|
handle = Marshaller.Malloc ((ulong)(IntPtr.Size * args.Length));
|
||||||
|
|
||||||
for (int i = 0; i < args.Length; i++)
|
for (int i = 0; i < args.Length; i++)
|
||||||
Marshal.WriteIntPtr (handle, i * IntPtr.Size, arg_ptrs [i]);
|
Marshal.WriteIntPtr (handle, i * IntPtr.Size, arg_ptrs [i]);
|
||||||
|
|
Loading…
Reference in a new issue