From 3bd5f335f75398382944386cd36cfa3224e991c4 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 26 Feb 2022 20:17:05 +0000 Subject: inflate: Add helper for getting decompressed data size Helper for another semi-typical operation: find out how big of a buffer should be allocated before decompressing. This can be useful when the stream container doesn't specify the decompressed size. Change-Id: I5f1536f809bb6f9bc6023120c024c3de7cea4269 --- firmware/include/inflate.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'firmware/include') diff --git a/firmware/include/inflate.h b/firmware/include/inflate.h index 7dae0448e3..1fce186f34 100644 --- a/firmware/include/inflate.h +++ b/firmware/include/inflate.h @@ -58,4 +58,13 @@ struct inflate_bufferctx { uint32_t inflate_buffer_reader(void* block, uint32_t block_size, void* ctx); uint32_t inflate_buffer_writer(const void* block, uint32_t block_size, void* ctx); +// dummy writer used if you just want to figure out how big the decompressed +// data will be. It does not actually write any data. Example usage: +// +// size_t size = 0; +// inflate(it, st, read, rctx, inflate_getsize_writer, &size); +// +// Now 'size' will be the size of the decompressed data (assuming no errors). +uint32_t inflate_getsize_writer(const void* block, uint32_t block_size, void* ctx); + #endif -- cgit v1.2.3