mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-01 05:45:59 +02:00
Zero-sized compression fixes
This commit is contained in:
parent
46fbba9712
commit
61222f8525
2 changed files with 10 additions and 18 deletions
|
@ -11,16 +11,12 @@ namespace utils
|
|||
[CallingConvention(.Stdcall), CLink]
|
||||
extern static Span<uint8> Compression_Decompress(void* ptr, int size);
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
extern static void Compression_Free(void* ptr);
|
||||
|
||||
public static Result<void> Compress(Span<uint8> inData, List<uint8> outData)
|
||||
{
|
||||
var outSpan = Compression_Compress(inData.Ptr, inData.Length);
|
||||
if ((outSpan.Length == 0) && (inData.Length != 0))
|
||||
return .Err;
|
||||
outData.AddRange(outSpan);
|
||||
Compression_Free(outSpan.Ptr);
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
|
@ -30,27 +26,24 @@ namespace utils
|
|||
if ((outSpan.Length == 0) && (inData.Length != 0))
|
||||
return .Err;
|
||||
outData.Insert(outData.Length, StringView((.)outSpan.Ptr, outSpan.Length));
|
||||
Compression_Free(outSpan.Ptr);
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public static Result<void> Decompress(Span<uint8> inData, List<uint8> outData)
|
||||
{
|
||||
var outSpan = Compression_Decompress(inData.Ptr, inData.Length);
|
||||
if ((outSpan.Length == 0) && (inData.Length != 0))
|
||||
if (outSpan == default)
|
||||
return .Err;
|
||||
outData.AddRange(outSpan);
|
||||
Compression_Free(outSpan.Ptr);
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public static Result<void> Decompress(Span<uint8> inData, String outData)
|
||||
{
|
||||
var outSpan = Compression_Decompress(inData.Ptr, inData.Length);
|
||||
if ((outSpan.Length == 0) && (inData.Length != 0))
|
||||
if (outSpan == default)
|
||||
return .Err;
|
||||
outData.Insert(outData.Length, StringView((.)outSpan.Ptr, outSpan.Length));
|
||||
Compression_Free(outSpan.Ptr);
|
||||
return .Ok;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue