Make public API have separate input/output dest size variables

This commit is contained in:
Jack Andersen 2019-06-13 14:32:25 -10:00
parent 55892696bb
commit b1b1ea05a0
2 changed files with 14 additions and 6 deletions

View File

@ -89,7 +89,10 @@ static constexpr uint32_t M4Marker = 0x10;
static constexpr uint32_t MaxMatchByLengthLen = 34; /* Max M3 len + 1 */ static constexpr uint32_t MaxMatchByLengthLen = 34; /* Max M3 len + 1 */
EResult decompress(const uint8_t* src, std::size_t src_size, EResult decompress(const uint8_t* src, std::size_t src_size,
uint8_t* dst, std::size_t& dst_size) { uint8_t* dst, std::size_t init_dst_size,
std::size_t& dst_size) {
dst_size = init_dst_size;
if (src_size < 3) { if (src_size < 3) {
dst_size = 0; dst_size = 0;
return EResult::InputOverrun; return EResult::InputOverrun;
@ -591,10 +594,12 @@ static EResult encode_lookback_match(uint8_t*& outp, const uint8_t* outp_end, co
} }
EResult compress(const uint8_t* src, std::size_t src_size, EResult compress(const uint8_t* src, std::size_t src_size,
uint8_t* dst, std::size_t& dst_size, DictBase& dict) { uint8_t* dst, std::size_t init_dst_size,
std::size_t& dst_size, DictBase& dict) {
EResult err; EResult err;
State s; State s;
auto& d = static_cast<DictImpl&>(dict); auto& d = static_cast<DictImpl&>(dict);
dst_size = init_dst_size;
uint8_t* outp = dst; uint8_t* outp = dst;
uint8_t* outp_end = dst + dst_size; uint8_t* outp_end = dst + dst_size;
uint32_t lit_len = 0; uint32_t lit_len = 0;

View File

@ -60,13 +60,16 @@ public:
}; };
EResult decompress(const uint8_t* src, std::size_t src_size, EResult decompress(const uint8_t* src, std::size_t src_size,
uint8_t* dst, std::size_t& dst_size); uint8_t* dst, std::size_t dst_size,
std::size_t& out_size);
EResult compress(const uint8_t* src, std::size_t src_size, EResult compress(const uint8_t* src, std::size_t src_size,
uint8_t* dst, std::size_t& dst_size, DictBase& dict); uint8_t* dst, std::size_t dst_size,
std::size_t& out_size, DictBase& dict);
inline EResult compress(const uint8_t* src, std::size_t src_size, inline EResult compress(const uint8_t* src, std::size_t src_size,
uint8_t* dst, std::size_t& dst_size) { uint8_t* dst, std::size_t dst_size,
std::size_t& out_size) {
Dict<> dict; Dict<> dict;
return compress(src, src_size, dst, dst_size, dict); return compress(src, src_size, dst, dst_size, out_size, dict);
} }
constexpr std::size_t compress_worst_size(std::size_t s) { constexpr std::size_t compress_worst_size(std::size_t s) {