Open eeyrw opened 8 years ago
You're right that this code is more confusing than it needs to be, particularly since it's the main real example of the library being used. It should be streamlined (as much as possible), and given some comments to explain the subtleties.
static int encoder_sink_read(config cfg, heatshrink_encoder hse, uint8_t data, size_t data_sz) { size_t out_sz = 4096; uint8_t out_buf[out_sz]; memset(out_buf, 0, out_sz); size_t sink_sz = 0; size_t poll_sz = 0; HSE_sink_res sres; HSE_poll_res pres; HSE_finish_res fres; io_handle out = cfg->out;
}
I found the fact that "data_sz" never have been changed. So branch “if (poll_sz == 0 && data_sz == 0)” won't execute except for zero data_sz. I thinks data_sz here might be substituted with sink_sz due to the symmetry.