[*] Modernize legacy compression API Compress
This commit is contained in:
parent
1ff9feb303
commit
39ef196c0a
@ -14,18 +14,30 @@ namespace Aurora::Compression
|
||||
{
|
||||
AUKN_SYM bool Compress(const Memory::MemoryViewRead &source, Memory::ByteBuffer &out, int uCompressionLevel)
|
||||
{
|
||||
if (!AuTryResize(out, source.length))
|
||||
if (!out.GetOrAllocateLinearWriteable(source.length))
|
||||
{
|
||||
return false;
|
||||
SysPushErrorMemory();
|
||||
return {};
|
||||
}
|
||||
|
||||
auto ret = ZSTD_compress(out.data(), out.size(), source.ptr, source.length, uCompressionLevel);
|
||||
auto ret = ZSTD_compress(out.writePtr, source.length, source.ptr, source.length, uCompressionLevel);
|
||||
if (ZSTD_isError(ret))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
out.resize(ret);
|
||||
out.writePtr += ret;
|
||||
|
||||
if (!out.flagCircular &&
|
||||
out.flagExpandable)
|
||||
{
|
||||
if (!AuTryDownsize(out, out.writePtr - out.base))
|
||||
{
|
||||
SysPushErrorMemory();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -54,8 +66,6 @@ namespace Aurora::Compression
|
||||
return false;
|
||||
}
|
||||
|
||||
auto startingSize = out.size();
|
||||
|
||||
auto view = out.GetOrAllocateLinearWriteable(inflatedLength);
|
||||
if (!view)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user