Name
lz77_uncompress
Synopsis
int lz77_uncompress(const unsigned char *compressed
, unsigned char **original
);
Return Value
Number of bytes in the restored data if uncompressing the data is successful, or -1 otherwise.
Description
Uses LZ77 to uncompress a buffer of data specified by
compressed
. It is assumed that the
buffer contains data previously compressed with
lz77_compress. The restored data is written
to a buffer returned in original
. Since
the amount of storage required in
original
may not be known to the
caller, lz77_uncompress dynamically allocates
the necessary storage using malloc. It is the
responsibility of the caller to free this storage using
free when it is no longer needed.
Complexity
O (n), where n is the number of symbols in the original data.
Get Mastering Algorithms with C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.