summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJooseok Park <jooseok.park@samsung.com>2017-03-30 09:49:48 +0900
committerJooseok Park <jooseok.park@samsung.com>2017-03-30 09:49:48 +0900
commit926a875c7354895df5a939ee3cbbe9572435dcc3 (patch)
tree2698594596013dc5d110bf482e9cbacafce22e86
parente49c80ed488c39a26022aec95944b309ec41c6f8 (diff)
downloadiotcon-926a875c7354895df5a939ee3cbbe9572435dcc3.tar.gz
iotcon-926a875c7354895df5a939ee3cbbe9572435dcc3.tar.bz2
iotcon-926a875c7354895df5a939ee3cbbe9572435dcc3.zip
- Change string to IntPtr to avoid to free char pointer in C# - Also, need to marshal pointer to string Change-Id: Iaa3851c99717b93cd923d6a77cabffa48ec3f63d
-rwxr-xr-xTizen.Network.IoTConnectivity/Interop/Interop.IoTConnectivity.Common.cs2
-rwxr-xr-xTizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/Attributes.cs8
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: