From 9a589e1f5221d1bd995b6c4fa73e3a074d4c2da4 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Thu, 17 Nov 2005 21:11:13 +0000 Subject: * add byte[] overloads for EntryGroup methods * cleanup string marshalling git-svn-id: file:///home/lennart/svn/public/avahi/trunk@999 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-sharp/Utility.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'avahi-sharp/Utility.cs') diff --git a/avahi-sharp/Utility.cs b/avahi-sharp/Utility.cs index f8b4ffd..b15161c 100644 --- a/avahi-sharp/Utility.cs +++ b/avahi-sharp/Utility.cs @@ -60,12 +60,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); + } + + 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); -- cgit