richox / libzling

fast and niubility compression library.
88 stars 20 forks source link

Make code useable as a library #2

Closed nemequ closed 9 years ago

nemequ commented 10 years ago

Same as https://github.com/richox/zlite/issues/2

I'm willing to provide a patch similar to the one I provided for zlite, but I would like some feedback on that patch first. The API I proposed in that patch is:

#define ZLITE_BLOCK_HEADER_LEN 8
#define ZLITE_BLOCK_MAX_UNCOMPRESSED_LEN (1 << 24)
#define ZLITE_WORK_MEM_LEN (sizeof(unsigned short) * ZLITE_BLOCK_MAX_UNCOMPRESSED_LEN)
#define ZLITE_BLOCK_MAX_COMPRESSED_LEN(uncompressed_len) (ZLITE_BLOCK_HEADER_LEN + 512 + uncompressed_len + (uncompressed_len / 5))
int zlite_compress_block(unsigned char* ibuf, int ilen, unsigned char* obuf, int olen, void* workmem);
int zlite_parse_block_header(unsigned char header[ZLITE_BLOCK_HEADER_LEN], int* rlen);
int zlite_decompress_block(unsigned char* ibuf, int ilen, unsigned char* obuf, int olen, int rlen, void* workmem);