Encoder: Change the way we reckon the number of items added

Instead of counting forward the number of items added, which meant we
couldn't know in cbot_encoder_close_container() whether we had added
enough, let's count backwards. The number is offset by 1 so we should be
at 1 if we added exactly as many items as we had expected to. Zero means
we added too many. Any other number means we added too few.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
4 files changed