Skip to content

Commit c7e5454

Browse files
committed
add tamp_compressor_full to the C api.
1 parent c62354c commit c7e5454

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tamp/_c_src/tamp/compressor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void tamp_compressor_sink(
206206
consumed_size = &consumed_size_proxy;
207207

208208
for(size_t i=0; i < input_size; i++){
209-
if(TAMP_UNLIKELY(compressor->input_size == sizeof(compressor->input)))
209+
if(TAMP_UNLIKELY(tamp_compressor_full(compressor)))
210210
break;
211211
compressor->input[input_add(compressor->input_size)] = input[i];
212212
compressor->input_size += 1;
@@ -248,7 +248,7 @@ tamp_res tamp_compressor_compress_cb(
248248
input_size -= consumed;
249249
(*input_consumed_size) += consumed;
250250
}
251-
if(TAMP_LIKELY(compressor->input_size == sizeof(compressor->input))){
251+
if(TAMP_LIKELY(tamp_compressor_full(compressor))){
252252
// Input buffer is full and ready to start compressing.
253253
size_t chunk_output_written_size;
254254
res = tamp_compressor_poll(compressor, output, output_size, &chunk_output_written_size);

tamp/_c_src/tamp/compressor.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ tamp_res tamp_compressor_poll(
122122
// backwards compatibility for old naming
123123
#define tamp_compressor_compress_poll tamp_compressor_poll
124124

125+
/**
126+
* @brief Check if the compressor's input buffer is full.
127+
*
128+
* @param[in] compressor TampCompressor object to check.
129+
*
130+
* @return true if the compressor is full, false otherwise.
131+
*/
132+
TAMP_ALWAYS_INLINE bool tamp_compressor_full(TampCompressor *compressor) {
133+
return compressor->input_size == sizeof(compressor->input);
134+
}
135+
125136
/**
126137
* @brief Completely flush the internal bit buffer. Makes output "complete".
127138
*

0 commit comments

Comments
 (0)