Skip to content

Commit

Permalink
fix: memory leak in metrics (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre authored Nov 28, 2024
1 parent 479d5bd commit 9324a6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
12 changes: 6 additions & 6 deletions dotnet-engine/Yggdrasil.Engine/FFI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ internal static class FFI
[DllImport("yggdrasilffi", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
private static extern void free_response(IntPtr ptr);
[DllImport("yggdrasilffi", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
private static extern void count_toggle(IntPtr ptr, string toggle_name, bool enabled);
private static extern IntPtr count_toggle(IntPtr ptr, string toggle_name, bool enabled);
[DllImport("yggdrasilffi", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
private static extern void count_variant(IntPtr ptr, string toggle_name, string variant_name);
private static extern IntPtr count_variant(IntPtr ptr, string toggle_name, string variant_name);
[DllImport("yggdrasilffi", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr should_emit_impression_event(IntPtr ptr, string toggle_name);
[DllImport("yggdrasilffi", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
Expand Down Expand Up @@ -75,14 +75,14 @@ public static void FreeResponse(IntPtr ptr)
free_response(ptr);
}

public static void CountToggle(IntPtr ptr, string toggle_name, bool enabled)
public static IntPtr CountToggle(IntPtr ptr, string toggle_name, bool enabled)
{
count_toggle(ptr, toggle_name, enabled);
return count_toggle(ptr, toggle_name, enabled);
}

public static void CountVariant(IntPtr ptr, string toggle_name, string variant_name)
public static IntPtr CountVariant(IntPtr ptr, string toggle_name, string variant_name)
{
count_variant(ptr, toggle_name, variant_name);
return count_variant(ptr, toggle_name, variant_name);
}

public static IntPtr ShouldEmitImpressionEvent(IntPtr ptr, string toggle_name)
Expand Down
2 changes: 1 addition & 1 deletion dotnet-engine/Yggdrasil.Engine/Yggdrasil.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Unleash.Yggdrasil</PackageId>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<YggdrasilCoreVersion>0.14.0</YggdrasilCoreVersion>
<Company>Bricks Software AS</Company>
<Authors>Unleash</Authors>
Expand Down
6 changes: 4 additions & 2 deletions dotnet-engine/Yggdrasil.Engine/YggdrasilEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ public void TakeState(string json)

public void CountFeature(string featureName, bool enabled)
{
FFI.CountToggle(state, featureName, enabled);
var responsePtr = FFI.CountToggle(state, featureName, enabled);
FFIReader.CheckResponse(responsePtr);
}

public void CountVariant(string featureName, string variantName)
{
FFI.CountVariant(state, featureName, variantName);
var responsePtr = FFI.CountVariant(state, featureName, variantName);
FFIReader.CheckResponse(responsePtr);
}

public ICollection<FeatureDefinition> ListKnownToggles()
Expand Down

0 comments on commit 9324a6d

Please sign in to comment.