mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Kind of fixed a memory leak
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using DirectX.Common;
|
||||
using GlitchyEngine.Core;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
namespace GlitchyEngine
|
||||
{
|
||||
@@ -15,6 +16,15 @@ namespace GlitchyEngine
|
||||
oldDest?.ReleaseRef();
|
||||
}
|
||||
|
||||
/// Releases the reference to destination, writes newValue into it and adds a reference to newValue.
|
||||
public static mixin SetReferenceVar<T>(T destination, T newValue) where T: var
|
||||
{
|
||||
var oldDest = destination;
|
||||
destination = newValue;
|
||||
destination?.AddRef();
|
||||
oldDest?.Release();
|
||||
}
|
||||
|
||||
/// Releases the reference to value and nullifies it.
|
||||
public static mixin ReleaseRefAndNullify<T>(T value) where T: RefCounter
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user