You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New to heatshrink, and I'm running into an issue where I'm getting stuck in a while loop while polling on what I imagine is an empty encoder.
uint8_t buf[32];
heatshrink_encoder_reset(&hse);
// some logic here that reads some file contents and sinks it into the encoder - it's possible that `heatshrink_encoder_sink` is not called at all herewhile (heatshrink_encoder_finish(&hse)==HSER_FINISH_MORE) {
heatshrink_encoder_poll(&hse, buf, 32, &num_compressed_bytes_output);
// do something with buf
}
In cases where the "some logic" part calls heatshrink_encoder_sink at least once, this works just fine
When heatshrink_encoder_sink never gets called, that while loop at the end continues forever and seems to be filling the buf with stuff from memory. I had expected heatshrink_encoder_finish(&hse)==HSER_FINISH_MORE to be true if nothing was sunk into the encoder, but clearly I"m missing something.
My current fix is just to sink a blank string into the encoder before starting to poll, and that seems to work out
New to heatshrink, and I'm running into an issue where I'm getting stuck in a while loop while polling on what I imagine is an empty encoder.
In cases where the "some logic" part calls
heatshrink_encoder_sink
at least once, this works just fineWhen
heatshrink_encoder_sink
never gets called, that while loop at the end continues forever and seems to be filling thebuf
with stuff from memory. I had expectedheatshrink_encoder_finish(&hse)==HSER_FINISH_MORE
to be true if nothing was sunk into the encoder, but clearly I"m missing something.My current fix is just to sink a blank string into the encoder before starting to poll, and that seems to work out
Any advice on the proper way to poll when there might not be anything sunk into the encoder?
The text was updated successfully, but these errors were encountered: