This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#18) Moved inline functions to a separate header
Moved a bunch of inline function to a separate `api_impl.h` header to avoid polluting too much the main header.
- Loading branch information
Showing
2 changed files
with
58 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
|
||
|
||
namespace lz4 { namespace api { | ||
|
||
inline int compressBound(int inputSize) | ||
{ | ||
return _detail::LZ4_compressBound(inputSize); | ||
}; | ||
|
||
inline int compressBound(const span<char> input) | ||
{ | ||
return _detail::LZ4_compressBound(input.length()); | ||
}; | ||
|
||
inline int compress_default(const span<char> source, span<char> dest) | ||
{ | ||
return _detail::LZ4_compress_default(source.data(), dest.data(), source.length(), dest.length()); | ||
}; | ||
|
||
inline int decompress_safe (const span<char> source, span<char> dest) | ||
{ | ||
return _detail::LZ4_decompress_safe(source.data(), dest.data(), source.length(), dest.length()); | ||
}; | ||
|
||
inline int sizeofState() | ||
{ | ||
return _detail::LZ4_sizeofState(); | ||
}; | ||
|
||
inline int compress_fast_extState(span<byte> state, const span<char> source, span<char> dest, int acceleration) | ||
{ | ||
return _detail::LZ4_compress_fast_extState(state.data(), source.data(), dest.data(), source.length(), dest.length(), acceleration); | ||
}; | ||
|
||
inline int compress_destSize (span<char>& source, span<char> dest) | ||
{ | ||
auto sourceSize = source.length(); | ||
volatile int sourceUsed = sourceSize; | ||
auto atExit = finally([&](){ | ||
source = source.subspan(sourceSize - sourceUsed); | ||
}); | ||
|
||
return _detail::LZ4_compress_destSize(source.data(), dest.data(), const_cast<int*>(&sourceUsed), dest.length()); | ||
}; | ||
|
||
inline int decompress_fast (const span<char> source, span<char> dest, int uncompressedSize) | ||
{ | ||
return _detail::LZ4_decompress_fast(source.data(), dest.data(), uncompressedSize); | ||
}; | ||
|
||
inline int decompress_safe_partial (const span<char> source, span<char> dest, int targetOutputSize) | ||
{ | ||
return _detail::LZ4_decompress_safe_partial (source.data(), dest.data(), source.length(), targetOutputSize, dest.length()); | ||
}; | ||
}; | ||
}; |