[Applications.WidgetControl] Use Marshal.FreeHGlobal() instead of Lib… (#5629)
authorkilig <inkyun.kil@samsung.com>
Mon, 13 Nov 2023 01:41:58 +0000 (10:41 +0900)
committerGitHub <noreply@github.com>
Mon, 13 Nov 2023 01:41:58 +0000 (10:41 +0900)
* [Applications.WidgetControl] Use Marshal.FreeHGlobal() instead of Libc.Free()

Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
* [Applications.Cion] Use Marshal.AllocHGlobal() instead of Libc.Malloc()

Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
---------

Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
Co-authored-by: pjh9216 <jh9216.park@samsung.com>
src/Tizen.Applications.Cion/Interop/Interop.Cion.cs
src/Tizen.Applications.Cion/Interop/Interop.Libraries.cs
src/Tizen.Applications.Cion/Tizen.Applications.Cion/ServerBase.cs
src/Tizen.Applications.WidgetControl/Interop/Interop.Libc.cs [deleted file]
src/Tizen.Applications.WidgetControl/Interop/Interop.Libraries.cs
src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs

index 75d81ba..2a10ed1 100644 (file)
@@ -34,8 +34,5 @@ internal static partial class Interop
             TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
             OperationFailed = -0x030C0000 | 0x01,
         }
-
-        [DllImport(Libraries.Libc, EntryPoint = "malloc")]
-        internal static extern IntPtr Malloc(int size);
     }
 }
index 0f6ed84..32af828 100644 (file)
@@ -19,6 +19,5 @@ internal static partial class Interop
     internal static partial class Libraries
     {
         public const string Cion = "libcion.so.1";
-        public const string Libc = "libc.so.6";
     }
 }
index 0d2c5a4..fb634d9 100644 (file)
@@ -135,7 +135,7 @@ namespace Tizen.Applications.Cion
                     Marshal.Copy(data, receivedData, 0, dataSize);
                     byte[] returnDataRaw = OnDataReceived(receivedData, new PeerInfo(clone));
                     returnDataSize = returnDataRaw.Length;
-                    returnData = Interop.Cion.Malloc(returnDataSize);
+                    returnData = Marshal.AllocHGlobal(returnDataSize);
                     Marshal.Copy(returnDataRaw, 0, returnData, returnDataSize);
                 });
             ret = Interop.CionServer.CionServerSetDataReceivedCb(_handle, _dataReceivedCb, IntPtr.Zero);
diff --git a/src/Tizen.Applications.WidgetControl/Interop/Interop.Libc.cs b/src/Tizen.Applications.WidgetControl/Interop/Interop.Libc.cs
deleted file mode 100644 (file)
index 979589f..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-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);
-    }
-}
index 3b5ec29..57a3645 100755 (executable)
@@ -19,6 +19,5 @@ internal static partial class Interop
     internal static partial class Libraries
     {
         public const string WidgetService = "libwidget_service.so.1";
-        public const string Libc = "libc.so.6";
     }
 }
index 0daff7d..d6888fb 100755 (executable)
@@ -707,11 +707,11 @@ namespace Tizen.Applications
             }
             w = new int[cnt1];
             Marshal.Copy(wPtr, w, 0, cnt1);
-            Interop.Libc.Free(wPtr);
+            Marshal.FreeHGlobal(wPtr);
 
             h = new int[cnt1];
             Marshal.Copy(hPtr, h, 0, cnt1);
-            Interop.Libc.Free(hPtr);
+            Marshal.FreeHGlobal(hPtr);
 
             err = Interop.WidgetService.GetSupportedSizeTypes(Id, ref cnt2, out typesPtr);
             switch (err)
@@ -734,7 +734,7 @@ namespace Tizen.Applications
 
             types = new int[cnt2];
             Marshal.Copy(typesPtr, types, 0, cnt2);
-            Interop.Libc.Free(typesPtr);
+            Marshal.FreeHGlobal(typesPtr);
 
             for (int i = 0; i < cnt1; i++)
             {