Exemplo n.º 1
0
size_t
gzip_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
{
	size_t dstlen = d_len;

	ASSERT(d_len <= s_len);

	if (z_compress_level(d_start, &dstlen, s_start, s_len, n) != Z_OK) {
		if (d_len != s_len)
			return (s_len);

		bcopy(s_start, d_start, s_len);
		return (s_len);
	}

	return (dstlen);
}
Exemplo n.º 2
0
static int
splat_zlib_test1_check(struct file *file, void *src, void *dst, void *chk,
    int level)
{
	size_t dst_len = BUFFER_SIZE;
	size_t chk_len = BUFFER_SIZE;
	int rc;

	memset(dst, 0, BUFFER_SIZE);
	memset(chk, 0, BUFFER_SIZE);

	rc = z_compress_level(dst, &dst_len, src, BUFFER_SIZE, level);
	if (rc != Z_OK) {
		splat_vprint(file, SPLAT_ZLIB_TEST1_NAME,
		    "Failed level %d z_compress_level(), %d\n", level, rc);
		return -EINVAL;
	}

	rc = z_uncompress(chk, &chk_len, dst, dst_len);
	if (rc != Z_OK) {
		splat_vprint(file, SPLAT_ZLIB_TEST1_NAME,
		    "Failed level %d z_uncompress(), %d\n", level, rc);
		return -EINVAL;
	}

	rc = memcmp(src, chk, BUFFER_SIZE);
	if (rc) {
		splat_vprint(file, SPLAT_ZLIB_TEST1_NAME,
		    "Failed level %d memcmp()), %d\n", level, rc);
		return -EINVAL;
	}

	splat_vprint(file, SPLAT_ZLIB_TEST1_NAME,
	    "Passed level %d, compressed %d bytes to %d bytes\n",
	    level, BUFFER_SIZE, (int)dst_len);

	return 0;
}
Exemplo n.º 3
0
int
z_compress(void *dst, size_t *dstlen, const void *src, size_t srclen)
{
	return (z_compress_level(dst, dstlen, src, srclen,
	    Z_DEFAULT_COMPRESSION));
}