压缩函数:
0 | QLZ_COMPRESSION_LEVEL |
1 | sizeof(qlz_state_compress) |
2 | sizeof(qlz_state_decompress) |
3 | QLZ_STREAMING_BUFFER |
6 | 1 if QLZ_MEMOMRY_SAFE is defined, otherwise 0 |
7 | QLZ_VERSION_MAJOR |
8 | QLZ_VERSION_MINOR |
9 | QLZ_VERSION_REVISION |
#define QLZ_COMPRESSION_LEVEL 1//#define QLZ_COMPRESSION_LEVEL 2
//#define QLZ_COMPRESSION_LEVEL 3 |
//#define QLZ_STREAMING_BUFFER 100000
//#define QLZ_STREAMING_BUFFER 1000000
Overlapping decompression
d = (decompressed size)
c = (compressed size).
← lower addresses | higher addresses → |
d + (d >> 3) + 400 – c bytes of space | c bytes of compressed data |
↑ destination
{
char *destination;
char original[] = “Test of overlapping decompression.
Five, six, seven, eight, nine, fifteen, sixteen, seventeen, fifteen, sixteen, seventeen.“; int d = strlen(original);
qlz_state_compress *state_compress = (qlz_state_compress *)malloc(sizeof(qlz_state_compress));
qlz_state_decompress *state_decompress = (qlz_state_decompress *)malloc(sizeof(qlz_state_decompress));
char *compressed = (char *)malloc(d + 400); int c = qlz_compress(original, compressed, d, state_compress);
destination = (char *)malloc(d + (d >> 3) + 400);
memmove(destination + d + (d >> 3) + 400 – c, compressed, c);
qlz_decompress(destination + d + (d >> 3) + 400 – c, destination, state_decompress);
destination[d] = 0;
printf(“%s”, destination);
return 0;
}
sizeof(char *) | 32 bits | 64 bits | ||||
QLZ_COMPRESSION_LEVEL |
1 | 2 | 3 | 1 | 2 | 3 |
sizeof(qlz_state_compress) | 36868 | 34820 | 266244 | 36872 | 67592 | 528392 |
sizeof(qlz_state_decompress) | 20484 | 34820 | 8 | 36872 | 67592 | 8 |