From cd4f4e2b20cace812672f0e0f5e842ed2e6ecf78 Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:40:33 +0900 Subject: [PATCH] Use Marshal.FreeHGlobal() instead of Libc.Free() (#5628) Signed-off-by: Hwankyu Jhun --- src/Tizen.Applications.Common/Interop/Interop.Libc.cs | 3 --- .../Tizen.Applications/AppControl.cs | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs index 81aacdd73c9..09c256e7db9 100644 --- a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs @@ -23,9 +23,6 @@ internal static partial class Interop { internal static partial class Libc { - [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Free(IntPtr ptr); - [DllImport(Libraries.Libc, EntryPoint = "getenv")] internal static extern IntPtr GetEnvironmentVariable(string name); diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index 3bd02e21ef6..60c213fb4d7 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -1335,9 +1335,9 @@ public bool TryGet(string key, out IEnumerable value) { IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i); stringList.Add(Marshal.PtrToStringAnsi(charArr)); - _ = Interop.Libc.Free(charArr); + Marshal.FreeHGlobal(charArr); } - _ = Interop.Libc.Free(valuePtr); + Marshal.FreeHGlobal(valuePtr); value = stringList; return true; } @@ -1491,9 +1491,9 @@ private IEnumerable GetDataCollection(string key) { IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i); valueArray.Add(Marshal.PtrToStringAnsi(charArr)); - _ = Interop.Libc.Free(charArr); + Marshal.FreeHGlobal(charArr); } - _ = Interop.Libc.Free(valuePtr); + Marshal.FreeHGlobal(valuePtr); } return valueArray; }