Skip to content

Commit

Permalink
Switch to bzalloc from NetObsBindings library
Browse files Browse the repository at this point in the history
  • Loading branch information
YorVeX committed Apr 24, 2023
1 parent f503a8b commit 0b72565
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion BrowserFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static unsafe void RefreshBrowserSource(Context* context)
{
Module.Log("filter_create called", ObsLogLevel.Debug);

var context = Module.bzalloc<Context>(); //TODO: change this after this was implemented: https://github.com/kostya9/NetObsBindings/issues/13
var context = ObsBmem.bzalloc<Context>();
context->Source = source;
context->Settings = settings;
fixed (byte* intervalId = "interval"u8)
Expand Down
14 changes: 0 additions & 14 deletions Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,6 @@ public static unsafe string ObsTextString(string identifier)
return resultString;
}
}

/// <summary>Allocates memory for an unmanaged structure using OBS memory management and initializes all fields in it to zero.</summary>
/// <typeparam name="T">The type of the structure to allocate.</typeparam>
/// <returns>A pointer to the allocated memory.</returns>
/// <remarks>Use <see cref="ObsInterop.ObsBmem.bfree(void*)"/> to free the memory.</remarks>
public static unsafe T* bzalloc<T>() where T : unmanaged
{
int structSize = Marshal.SizeOf<T>();
var context = (T*)ObsBmem.bmalloc((nuint)structSize);
byte* structBytes = (byte*)context;
for (int index = 0; index < structSize; index++)
structBytes[index] = 0;
return context;
}
#endregion Helper methods

#region OBS module API methods
Expand Down

0 comments on commit 0b72565

Please sign in to comment.