This PR adds two functions fz_compress_writer and fz_decompress_writer which mirror fz_compress and fz_decompress but take a writer function rather than a destination buffer.
Where the original functions take char *dest, int dest_capacity and need a preallocated buffer, the new functions take a writer function (int (*dest_writer)(const char *buf, size_t len, void *arg)) and an argument for it.
Using these functions it may be possible (depending on the use case) to avoid the overhead of a memcpy. These functions also remove the wasteful need to call fz_compress or fz_decompress twice if the destination buffer is too small.
This PR adds two functions
fz_compress_writer
andfz_decompress_writer
which mirrorfz_compress
andfz_decompress
but take a writer function rather than a destination buffer.Where the original functions take
char *dest, int dest_capacity
and need a preallocated buffer, the new functions take a writer function (int (*dest_writer)(const char *buf, size_t len, void *arg)
) and an argument for it.Using these functions it may be possible (depending on the use case) to avoid the overhead of a
memcpy
. These functions also remove the wasteful need to callfz_compress
orfz_decompress
twice if the destination buffer is too small.