Skip to content

Commit

Permalink
use IntPtr to free memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Bujak committed Sep 12, 2023
1 parent d084c6e commit 48d04f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 4 additions & 3 deletions languages/csharp/Bitwarden.Sdk/BitwardenLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Bitwarden.Sdk;

Expand All @@ -8,7 +9,7 @@ internal static class BitwardenLibrary
private static extern BitwardenSafeHandle init(string settings);

[DllImport("bitwarden_c", CallingConvention = CallingConvention.Cdecl)]
private static extern void free_mem(BitwardenSafeHandle handle);
private static extern void free_mem(IntPtr handle);

[DllImport("bitwarden_c", CallingConvention = CallingConvention.Cdecl)]
private static extern string run_command(string json, BitwardenSafeHandle handle);
Expand All @@ -18,7 +19,7 @@ internal static BitwardenSafeHandle Init(string settings)
return init(settings);
}

internal static void FreeMemory(BitwardenSafeHandle handle)
internal static void FreeMemory(IntPtr handle)
{
free_mem(handle);
}
Expand Down
2 changes: 1 addition & 1 deletion languages/csharp/Bitwarden.Sdk/BitwardenSafeHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public BitwardenSafeHandle() : base(true)

protected override bool ReleaseHandle()
{
BitwardenLibrary.FreeMemory(this);
BitwardenLibrary.FreeMemory(handle);
return true;
}
}
4 changes: 1 addition & 3 deletions languages/csharp/Bitwarden.Sdk/ProjectsClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Bitwarden.Sdk;
namespace Bitwarden.Sdk;


public class ProjectsClient
Expand Down

0 comments on commit 48d04f5

Please sign in to comment.