Author: mkestner
Date: 2007-11-08 12:29:53 -0500 (Thu, 08 Nov 2007)
New Revision: 89219

Modified:
   branches/gtk-sharp-2-10-branch/ChangeLog
   branches/gtk-sharp-2-10-branch/glib/Marshaller.cs
Log:

2007-11-08  Mike Kestner  <[EMAIL PROTECTED]>

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


Modified: branches/gtk-sharp-2-10-branch/ChangeLog
===================================================================
--- branches/gtk-sharp-2-10-branch/ChangeLog    2007-11-08 17:27:13 UTC (rev 
89218)
+++ branches/gtk-sharp-2-10-branch/ChangeLog    2007-11-08 17:29:53 UTC (rev 
89219)
@@ -1,3 +1,8 @@
+2007-11-08  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * glib/Marshaller.cs: new null-terminated string[] marshaler from
+       Mono.Unix with adaptations by Michael Hutchinson.
+
 2007-08-02  Mike Kestner  <[EMAIL PROTECTED]>
 
        * generator/OpaqueGen.cs : #if out the Copy override generation 

Modified: branches/gtk-sharp-2-10-branch/glib/Marshaller.cs
===================================================================
--- branches/gtk-sharp-2-10-branch/glib/Marshaller.cs   2007-11-08 17:27:13 UTC 
(rev 89218)
+++ branches/gtk-sharp-2-10-branch/glib/Marshaller.cs   2007-11-08 17:29:53 UTC 
(rev 89219)
@@ -133,6 +133,24 @@
                                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.
                //

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to