Name

huffman_compress

Synopsis

int huffman_compress(const unsigned char *original, unsigned char **compressed, 
   int size);

Return Value

Number of bytes in the compressed data if compressing the data is successful, or -1 otherwise.

Description

Uses Huffman coding to compress a buffer of data specified by original, which contains size bytes. The compressed data is written to a buffer returned in compressed. Since the amount of storage required in compressed is unknown to the caller, huffman_compress 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset