Use Marshal.FreeHGlobal() instead of Libc.Free() (#5628)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Tue, 17 Oct 2023 04:40:33 +0000 (13:40 +0900)
committerGitHub <noreply@github.com>
Tue, 17 Oct 2023 04:40:33 +0000 (13:40 +0900)
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.Libc.cs
src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs

index 81aacdd..09c256e 100644 (file)
@@ -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);
 
index 3bd02e2..60c213f 100755 (executable)
@@ -1335,9 +1335,9 @@ namespace Tizen.Applications
                     {
                         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 @@ namespace Tizen.Applications
                     {
                         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;
             }