diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2019-07-12 00:26:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-12 00:26:15 (GMT) |
commit | 23bd36918e8d0f312998d062c9b01001a5c29f17 (patch) | |
tree | ca3a8e2f487f1889ca81d48a6295cdf95edba82a | |
parent | eb6b599a50db0c144f4f8f5cd2d7e8e480c31d4e (diff) | |
parent | 771a7192d6aa46e5c136ded366a216af60df3583 (diff) | |
download | lz4-23bd36918e8d0f312998d062c9b01001a5c29f17.zip lz4-23bd36918e8d0f312998d062c9b01001a5c29f17.tar.gz lz4-23bd36918e8d0f312998d062c9b01001a5c29f17.tar.bz2 |
Merge pull request #751 from hamidzr/simple-buffer-example-input
simple buffer example minor input update. fixes #750
-rw-r--r-- | examples/simple_buffer.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/simple_buffer.c b/examples/simple_buffer.c index 027fc85..ea57022 100644 --- a/examples/simple_buffer.c +++ b/examples/simple_buffer.c @@ -38,7 +38,7 @@ int main(void) { /* Compression */ // We'll store some text into a variable pointed to by *src to be compressed later. - const char* const src = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; + const char* const src = "Lorem ipsum dolor sit amet, hhhhhhhhhhhhhhhhhhhhhhh"; // The compression function needs to know how many bytes exist. Since we're using a string, we can use strlen() + 1 (for \0). const int src_size = (int)(strlen(src) + 1); // LZ4 provides a function that will tell you the maximum size of compressed output based on input data via LZ4_compressBound(). @@ -55,7 +55,8 @@ int main(void) { if (compressed_data_size <= 0) run_screaming("A 0 or negative result from LZ4_compress_default() indicates a failure trying to compress the data. ", 1); if (compressed_data_size > 0) - printf("We successfully compressed some data!\n"); + printf("We successfully compressed some data! Ratio: %.2f\n", + (float) compressed_data_size/src_size); // 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. compressed_data = (char *)realloc(compressed_data, (size_t)compressed_data_size); |