Dhammika, > + // Check if we had an error in previous attempt. > + if (unlikely (!(static_cast<T*> (this)->next))) > + return (size_t) -1; > + I think this won't work. The next step of the decoding state machine is performed here irrespective of whether previous step was fully processed or not. Martin