in reply to [XS] sv_setpv change in behaviour with perl-5.42.0 and later

You're seeing Copy-on-Write (COW) affects. Post 5.40, $buffer's string buffer is being shared with the (constant folded at compiletime) constant SV's buffer which is holding the value of 'z' x 60. When $buffer is assigned to, the COW mechanism leaps into action, and it's given its own string buffer (only as big as it needs to be) to store the changed value.

Dave.

  • Comment on Re: [XS] sv_setpv change in behaviour with perl-5.42.0 and later