1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only */ 2 3 #ifndef _COMMONLIB_COMPRESSION_H_ 4 #define _COMMONLIB_COMPRESSION_H_ 5 6 #include <stddef.h> 7 8 /* Decompresses an LZ4F image (multiple LZ4 blocks with frame header) from src 9 * to dst, ensuring that it doesn't read more than srcn bytes and doesn't write 10 * more than dstn. Buffer sizes must stay below 2GB. Can decompress files loaded 11 * to the end of a buffer in-place, as long as buffer is larger than the final 12 * output size. (Usually just a few bytes, but may be up to (8 + dstn/255) in 13 * worst case. Will reliably return an error if buffer was too small.) 14 * Returns amount of decompressed bytes, or 0 on error. 15 */ 16 size_t ulz4fn(const void *src, size_t srcn, void *dst, size_t dstn); 17 18 /* Same as ulz4fn() but does not perform any bounds checks. */ 19 size_t ulz4f(const void *src, void *dst); 20 21 #endif /* _COMMONLIB_COMPRESSION_H_ */ 22