Use GLib.Marshaller.Free instead of calling g_free directly
Using the GLib.Marshaller.Free method means we don't need to have the g_free function definition duplicated all over the place.
This commit is contained in:
parent
f067f5112d
commit
32d10bd319
13 changed files with 16 additions and 52 deletions
|
@ -26,9 +26,6 @@ namespace Gdk {
|
|||
|
||||
public partial class Keymap {
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free(IntPtr ptr);
|
||||
|
||||
[DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool gdk_keymap_get_entries_for_keycode(IntPtr raw, uint hardware_keycode, out IntPtr keys, out IntPtr keyvals, out int n_entries);
|
||||
|
||||
|
@ -46,8 +43,8 @@ namespace Gdk {
|
|||
keyvals [i] = (uint) tmp [i];
|
||||
keys [i] = KeymapKey.New (ptr);
|
||||
}
|
||||
g_free (key_ptr);
|
||||
g_free (keyval_ptr);
|
||||
GLib.Marshaller.Free (key_ptr);
|
||||
GLib.Marshaller.Free (keyval_ptr);
|
||||
} else {
|
||||
keys = new KeymapKey [0];
|
||||
keyvals = new uint [0];
|
||||
|
@ -67,7 +64,7 @@ namespace Gdk {
|
|||
IntPtr ptr = new IntPtr ((long) key_ptr + i * Marshal.SizeOf (typeof (KeymapKey)));
|
||||
result [i] = KeymapKey.New (ptr);
|
||||
}
|
||||
g_free (key_ptr);
|
||||
GLib.Marshaller.Free (key_ptr);
|
||||
return result;
|
||||
} else
|
||||
return new KeymapKey [0];
|
||||
|
|
|
@ -235,9 +235,6 @@ namespace Gdk {
|
|||
return ret;
|
||||
}
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libgdk_pixbuf-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern unsafe bool gdk_pixbuf_save_to_bufferv (IntPtr raw, out IntPtr buffer, out IntPtr buffer_size, IntPtr type, IntPtr[] option_keys, IntPtr[] option_values, out IntPtr error);
|
||||
|
||||
|
@ -282,7 +279,7 @@ namespace Gdk {
|
|||
throw new GLib.GException (error);
|
||||
byte[] result = new byte [(int)buffer_size];
|
||||
Marshal.Copy (buffer, result, 0, (int) buffer_size);
|
||||
g_free (buffer);
|
||||
GLib.Marshaller.Free (buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,9 +190,6 @@ namespace GLib {
|
|||
return fullname + "Adapter";
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr item);
|
||||
|
||||
[DllImport (Global.GObjectNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_object_unref (IntPtr item);
|
||||
|
||||
|
@ -205,7 +202,7 @@ namespace GLib {
|
|||
} else if (typeof (GLib.IWrapper).IsAssignableFrom (element_type)) {
|
||||
g_object_unref (NthData (i));
|
||||
} else {
|
||||
g_free (NthData (i));
|
||||
Marshaller.Free (NthData (i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,9 +83,6 @@ namespace GLib {
|
|||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_object_unref (IntPtr item);
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr item);
|
||||
|
||||
void Dispose (bool disposing)
|
||||
{
|
||||
if (Handle == IntPtr.Zero)
|
||||
|
@ -99,7 +96,7 @@ namespace GLib {
|
|||
else if (typeof (GLib.Opaque).IsAssignableFrom (element_type))
|
||||
GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
|
||||
else
|
||||
g_free (NthData (i));
|
||||
Marshaller.Free (NthData (i));
|
||||
}
|
||||
|
||||
if (managed)
|
||||
|
|
|
@ -24,9 +24,6 @@ namespace Gtk {
|
|||
unsafe static extern void gtk_icon_set_get_sizes (
|
||||
IntPtr raw, out int *pointer_to_enum, out int n_sizes);
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
unsafe static extern void g_free (int *mem);
|
||||
|
||||
/// <summary> Sizes Property </summary>
|
||||
/// <remarks> To be completed </remarks>
|
||||
public Gtk.IconSize [] Sizes {
|
||||
|
@ -42,7 +39,7 @@ namespace Gtk {
|
|||
for (int i = 0; i < length; i++)
|
||||
retval [i] = (Gtk.IconSize) pointer_to_enum [i];
|
||||
|
||||
g_free (pointer_to_enum);
|
||||
GLib.Marshaller.Free ((IntPtr)pointer_to_enum);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -61,9 +61,6 @@ namespace Gtk {
|
|||
Set(type, format, data, data.Length);
|
||||
}
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr ptr);
|
||||
|
||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool gtk_selection_data_get_targets(IntPtr raw, out IntPtr targets, out int n_atoms);
|
||||
|
||||
|
@ -77,7 +74,7 @@ namespace Gtk {
|
|||
IntPtr atom = Marshal.ReadIntPtr (target_ptr, count * IntPtr.Size);
|
||||
result [i] = new Gdk.Atom (atom);
|
||||
}
|
||||
g_free (target_ptr);
|
||||
GLib.Marshaller.Free (target_ptr);
|
||||
return result;
|
||||
} else
|
||||
return new Gdk.Atom [0];
|
||||
|
|
|
@ -25,9 +25,6 @@ namespace Pango {
|
|||
|
||||
public partial class Context {
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libpango-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void pango_context_list_families(IntPtr raw, out IntPtr families, out int n_families);
|
||||
|
||||
|
@ -44,7 +41,7 @@ namespace Pango {
|
|||
result [i] = GLib.Object.GetObject (fam_ptr) as FontFamily;
|
||||
}
|
||||
|
||||
g_free (array_ptr);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ namespace Pango {
|
|||
|
||||
public partial class Coverage {
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libpango-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void pango_coverage_to_bytes (IntPtr raw, out IntPtr bytes, out int n_bytes);
|
||||
|
||||
|
@ -38,7 +35,7 @@ namespace Pango {
|
|||
pango_coverage_to_bytes (Handle, out array_ptr, out count);
|
||||
bytes = new byte [count];
|
||||
Marshal.Copy (array_ptr, bytes, 0, count);
|
||||
g_free (array_ptr);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ namespace Pango {
|
|||
|
||||
public partial class FontFamily {
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libpango-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void pango_font_family_list_faces(IntPtr raw, out IntPtr faces, out int n_faces);
|
||||
|
||||
|
@ -44,7 +41,7 @@ namespace Pango {
|
|||
result [i] = GLib.Object.GetObject (fam_ptr) as FontFace;
|
||||
}
|
||||
|
||||
g_free (array_ptr);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ namespace Pango {
|
|||
|
||||
public partial class FontMap {
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libpango-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void pango_font_map_list_families(IntPtr raw, out IntPtr families, out int n_families);
|
||||
|
||||
|
@ -44,7 +41,7 @@ namespace Pango {
|
|||
result [i] = GLib.Object.GetObject (fam_ptr) as FontFamily;
|
||||
}
|
||||
|
||||
g_free (array_ptr);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,6 @@ namespace Pango {
|
|||
accel_char = GLib.Marshaller.GUnicharToChar (ucs4_accel_char);
|
||||
}
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libpango-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void pango_layout_get_log_attrs (IntPtr raw, out IntPtr attrs, out int n_attrs);
|
||||
|
||||
|
@ -74,7 +71,7 @@ namespace Pango {
|
|||
result [i] = LogAttr.New (fam_ptr);
|
||||
}
|
||||
|
||||
g_free (array_ptr);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Pango {
|
|||
|
||||
}
|
||||
Marshal.Copy (array_ptr, ranges, 0, count);
|
||||
g_free (array_ptr);
|
||||
GLib.Marshaller.Free (array_ptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ namespace Pango {
|
|||
|
||||
public partial class TabArray {
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_free (IntPtr raw);
|
||||
|
||||
[DllImport ("libpango-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void pango_tab_array_get_tabs (IntPtr raw, out IntPtr alignments, out IntPtr locations);
|
||||
|
||||
|
@ -45,8 +42,8 @@ namespace Pango {
|
|||
Marshal.Copy (align_ptr, tmp, 0, sz);
|
||||
for (int i = 0; i < sz; i++)
|
||||
alignments [i] = (TabAlign) tmp [i];
|
||||
g_free (align_ptr);
|
||||
g_free (loc_ptr);
|
||||
GLib.Marshaller.Free (align_ptr);
|
||||
GLib.Marshaller.Free (loc_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue