From 926a875c7354895df5a939ee3cbbe9572435dcc3 Mon Sep 17 00:00:00 2001 From: Jooseok Park Date: Thu, 30 Mar 2017 09:49:48 +0900 Subject: Change Interop for iotcon_attributes_get_str() - Change string to IntPtr to avoid to free char pointer in C# - Also, need to marshal pointer to string Change-Id: Iaa3851c99717b93cd923d6a77cabffa48ec3f63d --- .../Interop/Interop.IoTConnectivity.Common.cs | 2 +- .../Tizen.Network.IoTConnectivity/Attributes.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs b/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs index d1d9af0..9b4fa48 100755 --- a/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs +++ b/Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs @@ -131,7 +131,7 @@ internal static partial class Interop internal static extern int GetDouble(IntPtr attributes, string key, out double val); [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_str")] - internal static extern int GetStr(IntPtr attributes, string key, out string val); + internal static extern int GetStr(IntPtr attributes, string key, out IntPtr val); [DllImport(Libraries.IoTCon, EntryPoint = "iotcon_attributes_get_byte_str")] internal static extern int GetByteStr(IntPtr attributes, string key, out IntPtr value, out int size); diff --git a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs index fd7012a..57a6e3a 100755 --- a/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs +++ b/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs @@ -63,7 +63,7 @@ namespace Tizen.Network.IoTConnectivity throw IoTConnectivityErrorFactory.GetException(ret); } - SetAttributes(attributesHandleToClone); + SetAttributes(_resourceAttributesHandle); } /// @@ -538,14 +538,16 @@ namespace Tizen.Network.IoTConnectivity } case Interop.IoTConnectivity.Common.DataType.String: { - string value; + IntPtr value; + string Str; ret = Interop.IoTConnectivity.Common.Attributes.GetStr(attributes, key, out value); if (ret != (int)IoTConnectivityError.None) { Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to get attributes"); throw IoTConnectivityErrorFactory.GetException(ret); } - _attributes.Add(key, value); + Str = Marshal.PtrToStringAnsi(value); + _attributes.Add(key, Str); break; } case Interop.IoTConnectivity.Common.DataType.ByteStr: -- cgit v1.2.3