Skip to content

Commit

Permalink
Use Marshal.FreeHGlobal() instead of Libc.Free() (#5628)
Browse files Browse the repository at this point in the history
Signed-off-by: Hwankyu Jhun <[email protected]>
  • Loading branch information
hjhun authored and JoonghyunCho committed Oct 31, 2023
1 parent f798f85 commit ea872dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/Tizen.Applications.Common/Interop/Interop.Libc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,9 +1335,9 @@ public bool TryGet(string key, out IEnumerable<string> 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;
}
Expand Down Expand Up @@ -1491,9 +1491,9 @@ private IEnumerable<string> 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;
}
Expand Down

0 comments on commit ea872dc

Please sign in to comment.