void srl_clear_encoder(pTHX_ srl_encoder_t *enc) { if (!SRL_ENC_HAVE_OPER_FLAG(enc, SRL_OF_ENCODER_DIRTY)) { warn("Sereal Encoder being cleared but in virgin state. That is unexpected."); } enc->depth = 0; if (enc->ref_seenhash != NULL) PTABLE_clear(enc->ref_seenhash); if (enc->str_seenhash != NULL) PTABLE_clear(enc->str_seenhash); if (enc->weak_seenhash != NULL) PTABLE_clear(enc->weak_seenhash); enc->pos = enc->buf_start; SRL_ENC_RESET_OPER_FLAG(enc, SRL_OF_ENCODER_DIRTY); }
SRL_STATIC_INLINE void srl_clear_decoder(pTHX_ srl_decoder_t *dec) { if (dec->buf_start == dec->buf_end) return; SRL_DEC_RESET_VOLATILE_FLAGS(dec); dec->buf_start = dec->buf_end = dec->pos = dec->save_pos = NULL; if (dec->weakref_av) av_clear(dec->weakref_av); PTABLE_clear(dec->ref_seenhash); if (dec->ref_stashes) { PTABLE_clear(dec->ref_stashes); PTABLE_clear(dec->ref_bless_av); } dec->recursion_depth = 0; }