Skip to content

Commit

Permalink
renamed flush compressor to finish (more traditional)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-aladev committed Aug 30, 2019
1 parent 6b5d28b commit 9a05d8f
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message (FATAL_ERROR "In-source builds are not allowed")
endif ()

set (LZWS_VERSION "1.1.1")
set (LZWS_VERSION "1.2.0")

if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set (CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "output directory for libraries")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Generic API:
- [lzws_decompressor_free_state.3](man/generic/lzws_decompressor_free_state.3.txt)
- [lzws_decompressor_get_initial_state.3](man/generic/lzws_decompressor_get_initial_state.3.txt)
- [lzws_decompressor_read_magic_header.3](man/generic/lzws_decompressor_read_magic_header.3.txt)
- [lzws_flush_compressor.3](man/generic/lzws_flush_compressor.3.txt)
- [lzws_finish_compressor.3](man/generic/lzws_finish_compressor.3.txt)
- [lzws_resize_buffer.3](man/generic/lzws_resize_buffer.3.txt)

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion man/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ add_man_target ("lzws_decompress.3" "man3")
add_man_target ("lzws_decompressor_free_state.3" "man3")
add_man_target ("lzws_decompressor_get_initial_state.3" "man3")
add_man_target ("lzws_decompressor_read_magic_header.3" "man3")
add_man_target ("lzws_flush_compressor.3" "man3")
add_man_target ("lzws_finish_compressor.3" "man3")
add_man_target ("lzws_resize_buffer.3" "man3")
2 changes: 1 addition & 1 deletion man/generic/lzws_compress.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ SEE ALSO
*lzws_compressor_write_magic_header*(3)
*lzws_compressor_get_initial_state*(3)
*lzws_compressor_free_state*(3)
*lzws_flush_compressor*(3)
*lzws_finish_compressor*(3)
2 changes: 1 addition & 1 deletion man/generic/lzws_compressor_free_state.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ SEE ALSO
*lzws_compressor_write_magic_header*(3)
*lzws_compressor_get_initial_state*(3)
*lzws_compress*(3)
*lzws_flush_compressor*(3)
*lzws_finish_compressor*(3)
2 changes: 1 addition & 1 deletion man/generic/lzws_compressor_get_initial_state.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ SEE ALSO
*lzws_compressor_write_magic_header*(3)
*lzws_compressor_free_state*(3)
*lzws_compress*(3)
*lzws_flush_compressor*(3)
*lzws_finish_compressor*(3)
2 changes: 1 addition & 1 deletion man/generic/lzws_compressor_write_magic_header.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ SEE ALSO
*lzws_compressor_get_initial_state*(3)
*lzws_compressor_free_state*(3)
*lzws_compress*(3)
*lzws_flush_compressor*(3)
*lzws_finish_compressor*(3)
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ LZWS(3)

NAME
----
lzws_flush_compressor - Flush compressor.
lzws_finish_compressor - Finish compressor.
You can't use *lzws_compress* after this call.
Use it only after stream was finished.


SYNOPSIS
--------
*#include <lzws/compressor/main.h>*

----
lzws_result_t lzws_flush_compressor(
lzws_result_t lzws_finish_compressor(
lzws_compressor_state_t* state_ptr,
uint8_t** destination_ptr, size_t* destination_length_ptr);
----
Expand All @@ -39,7 +41,7 @@ See header file *lzws/compressor/common.h* for more details about other results.

DESCRIPTION
-----------
Compressor requires flush after *lzws_compress*.
Compressor requires finish after *lzws_compress*.

This function writes compressed tail to destination.
It is possible that it won't be enough destination.
Expand All @@ -51,11 +53,11 @@ It also decreases *destination_length_ptr*.

PSEUDO EXAMPLE
--------------
You want to flush compressor after several portions of data.
You want to finish compressor after several portions of data.

----
while (true) {
lzws_result_t result = lzws_flush_compressor(
lzws_result_t result = lzws_finish_compressor(
state_ptr,
&destination, &destination_length);

Expand Down
5 changes: 4 additions & 1 deletion src/compressor/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ lzws_result_t lzws_compress(lzws_compressor_state_t* state_ptr, uint8_t** source
}
}

lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr)
lzws_result_t lzws_finish_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr)
{
switch (state_ptr->status) {
case LZWS_COMPRESSOR_WRITE_HEADER:
Expand Down Expand Up @@ -134,3 +134,6 @@ lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t*
return LZWS_COMPRESSOR_UNKNOWN_STATUS;
}
}

lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr)
__attribute__((weak, alias("lzws_finish_compressor")));
5 changes: 4 additions & 1 deletion src/compressor/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
lzws_result_t lzws_compress(lzws_compressor_state_t* state_ptr, uint8_t** source_ptr, size_t* source_length_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr);

// Use this function when you have no more source (received EOF for example).
lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr);
lzws_result_t lzws_finish_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr);

lzws_result_t lzws_flush_compressor(lzws_compressor_state_t* state_ptr, uint8_t** destination_ptr, size_t* destination_length_ptr)
__attribute__((deprecated));

#endif // LZWS_COMPRESSOR_MAIN_H
4 changes: 2 additions & 2 deletions src/examples/generic/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ int main()
return 4;
}

result = lzws_flush_compressor(compressor_state_ptr, &remaining_compressor_buffer, &remaining_compressor_buffer_length);
result = lzws_finish_compressor(compressor_state_ptr, &remaining_compressor_buffer, &remaining_compressor_buffer_length);
if (result != 0) {
LZWS_LOG_ERROR("flush compressor failed");
LZWS_LOG_ERROR("finish compressor failed");

lzws_compressor_free_state(compressor_state_ptr);
free(compressor_buffer);
Expand Down
2 changes: 1 addition & 1 deletion src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static inline lzws_result_t compress_data(
}

COMPRESS_WITH_READ_WRITE_BUFFERS(&lzws_compress, state_ptr, &source, &source_length, &destination, &destination_length);
COMPRESS_WITH_READ_WRITE_BUFFERS(&lzws_flush_compressor, state_ptr, &destination, &destination_length);
COMPRESS_WITH_READ_WRITE_BUFFERS(&lzws_finish_compressor, state_ptr, &destination, &destination_length);

return write_remaining_destination_buffer(destination_file, destination_buffer, destination_buffer_length, destination_length, quiet);
}
Expand Down
2 changes: 1 addition & 1 deletion src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static inline lzws_result_t compress_data(
}

COMPRESS_WITH_WRITE_BUFFER(&lzws_compress, state_ptr, &source, &source_length, &destination_buffer, &destination_buffer_length);
COMPRESS_WITH_WRITE_BUFFER(&lzws_flush_compressor, state_ptr, &destination_buffer, &destination_buffer_length);
COMPRESS_WITH_WRITE_BUFFER(&lzws_finish_compressor, state_ptr, &destination_buffer, &destination_buffer_length);

FLUSH_DESTINATION_BUFFER();

Expand Down

0 comments on commit 9a05d8f

Please sign in to comment.