Example #1
0
int64_t lzbench_lzrw_compress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t level, size_t workmem, size_t)
{
    uint32_t complen = 0;
    switch (level)
    {
    default:
    case 1:
        lzrw1_compress((uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen);
        break;
    case 2:
        lzrw1a_compress(COMPRESS_ACTION_COMPRESS, (uint8_t*)workmem, (uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen);
        break;
    case 3:
        lzrw2_compress(COMPRESS_ACTION_COMPRESS, (uint8_t*)workmem, (uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen);
        break;
    case 4:
        lzrw3_compress(COMPRESS_ACTION_COMPRESS, (uint8_t*)workmem, (uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen);
        break;
    case 5:
        lzrw3a_compress(COMPRESS_ACTION_COMPRESS, (uint8_t*)workmem, (uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen);
        break;
    }

    return complen;
}
Example #2
0
void compare (UBYTE* source,
	      UBYTE* destination,
	      ULONG bytes) {

  ULONG compressedSize;
  ULONG decompressedSize;

  /* Make a copy of the source page so that we have a version
     of the source that is guaranteed to be unmolested. */
  UBYTE* copy = (UBYTE*)malloc(sizeof(UBYTE) * bytes);
  memcpy ((void*)copy, (void*)source, sizeof (UBYTE) * bytes);

  /* Compress and then decompress the data. */
  lzrw1_compress(copy, bytes, destination, &compressedSize);
  lzrw1_decompress(destination,
		   compressedSize,
		   copy,
		   &decompressedSize);

  /* Compare the decompressed data to the original. */
  if (bytes != decompressedSize) {
    printf("Differed in size!\n");
  }
  if (memcmp ((void*)source, (void*)copy, sizeof (UBYTE) * bytes) == 0) {
    printf ("Matched\n");
  } else {
    unsigned int byte;
    printf ("Differed...sadness...\n");
    printf ("\tsource\t\tcopy\n");
    for (byte = 0; byte < bytes; byte++) {
      printf("\t%8lx\t%8lx\n", source[byte], copy[byte]);
    }
  }

  printf("\n");

}