run_screaming("A negative result from LZ4_compress_default indicates a failure trying to compress the data. See exit code (echo $?) for value returned.",return_value);
if(return_value==0)
run_screaming("A result of 0 means compression worked, but was stopped because the destination buffer couldn't hold all the information.",1);
if(return_value>0)
printf("We successfully compressed some data!\n");
// Not only does a positive return_value mean success, the value returned == the number of bytes required. You can use this to
// realloc() *compress_data to free up memory, if desired. We'll do so just to demonstrate the concept.
run_screaming("A negative result from LZ4_decompress_fast indicates a failure trying to decompress the data. See exit code (echo $?) for value returned.",return_value);
if(return_value==0)
run_screaming("I'm not sure this function can ever return 0. Documentation in lz4.h doesn't indicate so.",1);
if(return_value>0)
printf("We successfully decompressed some data!\n");
// Not only does a positive return value mean success, the value returned == the number of bytes read from the compressed_data
// stream. I'm not sure there's ever a time you'll need to know this in most cases...
/* Validation */
// We should be able to compare our original *src with our *new_src and be byte-for-byte identical.
if(memcmp(src,new_src,src_size)!=0)
run_screaming("Validation failed. *src and *new_src are not identical.",1);
printf("Validation done. The string we ended up with is:\n%s\n",new_src);