2007-11-08 Mike Kestner <mkestner@novell.com>

* glib/Marshaller.cs: new null-terminated string[] marshaler from
	Mono.Unix with adaptations by Michael Hutchinson.

svn path=/trunk/gtk-sharp/; revision=89218
This commit is contained in:
Mike Kestner 2007-11-08 17:27:13 +00:00
parent 5882ecf29a
commit de78d57176
2 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2007-11-08 Mike Kestner <mkestner@novell.com>
* glib/Marshaller.cs: new null-terminated string[] marshaler from
Mono.Unix with adaptations by Michael Hutchinson.
2007-11-02 Mike Kestner <mkestner@novell.com>
* glib/SList.cs:

View File

@ -133,6 +133,24 @@ namespace GLib {
return ret.Replace ("%", "%%");
}
public static string[] PtrToStringArrayGFree (IntPtr string_array)
{
if (string_array == IntPtr.Zero)
return new string [0];
int count = 0;
while (Marshal.ReadIntPtr (string_array, count*IntPtr.Size) != IntPtr.Zero)
++count;
string[] members = new string[count];
for (int i = 0; i < count; ++i) {
IntPtr s = Marshal.ReadIntPtr (string_array, i * IntPtr.Size);
members[i] = GLib.Marshaller.PtrToStringGFree (s);
}
GLib.Marshaller.Free (string_array);
return members;
}
// Argv marshalling -- unpleasantly complex, but
// don't know of a better way to do it.
//