--- liblzf/lzf.h 2012/12/10 20:21:28 1.16 +++ liblzf/lzf.h 2012/12/10 20:46:06 1.17 @@ -46,7 +46,12 @@ ** ***********************************************************************/ -#define LZF_VERSION 0x0105 /* 1.5, API version */ +/* API version (major * 256 + minor) + * major API version gets bumped on incompatible changes. + * minor API version gets bumped on compatible changes. + * 1.5 => 1.6: add LZF_MAX_COMPRESSED_SIZE + */ +#define LZF_VERSION 0x0106 /* * Compress in_len bytes stored at the memory block starting at @@ -78,6 +83,17 @@ void *out_data, unsigned int out_len); /* + * The maximum out_len that needs to be allocated to make sure + * any input data can be compressed without overflowing the output + * buffer, i.e. maximum out_len = LZF_MAX_COMPRESSED_SIZE (in_len). + * This is useful if you don't want to bother with the case of + * incompressible data and just want to provide a buffer that is + * guaranteeed to be big enough. + * This macro can be used at preprocessing time. + */ +#define LZF_MAX_COMPRESSED_SIZE(n) ((n) * 33 / 32 + 1) + +/* * Decompress data compressed with some version of the lzf_compress * function and stored at location in_data and length in_len. The result * will be stored at out_data up to a maximum of out_len characters.