]> git.meshlink.io Git - catta/blobdiff - avahi-sharp/Utility.cs
build doxygen docs for avahi-ui
[catta] / avahi-sharp / Utility.cs
index f8b4ffd8982857d55b65f603f839efb666cfa6fd..9081b011dc210a1e631ee5470021b9354f4e6221 100644 (file)
@@ -24,7 +24,9 @@ using System.Net;
 using System.Text;
 using System.Runtime.InteropServices;
 using Mono.Unix;
+using Mono.Unix.Native;
 
+using Stdlib = Mono.Unix.Native.Stdlib;
 
 namespace Avahi
 {
@@ -60,12 +62,20 @@ namespace Avahi
             return ret;
         }
 
-        public static IntPtr StringToPtr (string str)
+        public static byte[] StringToBytes (string str)
+        {
+            if (str == null)
+                return null;
+
+            return Encoding.UTF8.GetBytes (str + "\0"); // lame.
+        }
+
+        private static IntPtr StringToPtr (string str)
         {
             if (str == null)
                 return IntPtr.Zero;
 
-            byte[] bytes = Encoding.UTF8.GetBytes (str);
+            byte[] bytes = Utility.StringToBytes (str);
             IntPtr buf = Stdlib.malloc ((uint) bytes.Length + 1);
             Marshal.Copy (bytes, 0, buf, bytes.Length);
             Marshal.WriteByte (buf, bytes.Length, 0);