diff options
author | Jooseok Park <jooseok.park@samsung.com> | 2017-03-30 09:49:48 +0900 |
---|---|---|
committer | Jooseok Park <jooseok.park@samsung.com> | 2017-03-30 09:49:48 +0900 |
commit | 926a875c7354895df5a939ee3cbbe9572435dcc3 (patch) | |
tree | 2698594596013dc5d110bf482e9cbacafce22e86 | |
parent | e49c80ed488c39a26022aec95944b309ec41c6f8 (diff) | |
download | iotcon-926a875c7354895df5a939ee3cbbe9572435dcc3.tar.gz iotcon-926a875c7354895df5a939ee3cbbe9572435dcc3.tar.bz2 iotcon-926a875c7354895df5a939ee3cbbe9572435dcc3.zip |
Change Interop for iotcon_attributes_get_str()submit/tizen/20170330.021710accepted/tizen/unified/20170330.223604accepted/tizen/tv/20170330.223526accepted/tizen/mobile/20170330.223511accepted/tizen/ivi/20170330.223553accepted/tizen/common/20170330.151704
- Change string to IntPtr to avoid to free char pointer in C#
- Also, need to marshal pointer to string
Change-Id: Iaa3851c99717b93cd923d6a77cabffa48ec3f63d
-rwxr-xr-x | Tizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs | 2 | ||||
-rwxr-xr-x | Tizen.Network.IoTConnectivity/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); } /// <summary> @@ -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: |