in reply to XS: how to destroy HV* that was used internally?

SvREFCNT_dec((SV*)hv);

All internal Perl data structures are derived from SV, so that you can do thinks like that.

Replies are listed 'Best First'.
Re^2: XS: how to destroy HV* that was used internally?
by OlegG (Monk) on Sep 18, 2014 at 08:43 UTC
    Thank you!
    Also found that for me it works without type casting. But, ok, I'll use it
    And after all I found similar question on stackoverflow with similar answer.

      That's because SvREFCNT_dec already casts for you. In fact, it casts in a way that will detect if the input was const, so doing SvREFCNT_dec((SV*)hv) instead of SvREFCNT_dec(hv) is actually harmful.

      If you ever use (SV*)x, consider using MUTABLE_SV(x) instead.