SHA256
forked from ADOFAIEditorForum/ADOFAIRenderer
Fix Little Memory Leak Risk
This commit is contained in:
1 parent
6bd4a8975e
commit
bc7a7eca75
3 files changed
+47
-11
No files matched your search
+10
-5
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using MelonLoader;
|
||||
|
||||
namespace ADOFAIRenderer.Util
|
||||
{
|
||||
@@ -13,11 +14,15 @@ namespace ADOFAIRenderer.Util
|
||||
|
||||
unsafe
|
||||
{
|
||||
// Create an unmanaged memory stream that wraps the native pointer
|
||||
// (This does not allocate new memory; it references the existing pointer)
|
||||
using var unmanagedStream = new UnmanagedMemoryStream((byte*)nativePtr, length);
|
||||
// Copy the data directly into your target stream
|
||||
unmanagedStream.CopyTo(destinationStream);
|
||||
try
|
||||
{
|
||||
var span = new ReadOnlySpan<byte>((void*)nativePtr, length);
|
||||
destinationStream.Write(span);
|
||||
}
|
||||
catch (IOException err)
|
||||
{
|
||||
Melon<RenderMod>.Logger.Error($"FFmpeg 파이프가 예상치 못하게 닫혔습니다: {err.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user