Introduction
liblzg is a minimal implementation of an LZ77 class compression library. The main characteristic of the library is that the decoding routine is very simple, fast and requires no extra memory (except for the encoded and decoded data buffers).
Functions
Compression
Here is a simple example of compressing an uncompressed data buffer (given as buf/bufSize).
unsigned char *encBuf;
encBuf = (unsigned char*) malloc(maxEncSize);
if (encBuf)
{
encSize =
LZG_Encode(buf, bufSize, encBuf, maxEncSize, NULL);
if (encSize)
{
}
else
fprintf(stderr, "Compression failed!\n");
free(encBuf);
}
else
fprintf(stderr, "Out of memory!\n");
Decompression
Here is a simple example of decompressing a compressed data buffer (given as buf/bufSize).
unsigned char *decBuf;
if (decSize)
{
decBuf = (unsigned char*) malloc(decSize);
if (decBuf)
{
decSize =
LZG_Decode(buf, bufSize, decBuf, decSize);
if (decSize)
{
}
else
printf("Decompression failed (bad data)!\n");
free(decBuf);
}
else
printf("Out of memory!\n");
}
else
printf("Bad input data!\n");