In a way, this is plausible, as assigning a fresh string is a good situation to release memory back to the OS.
I'm not sure if pre-/resizing the buffer for a scalar still survives the various machinations. Obviously it breaks for sv_setpv, but I can see that breaking (fictional) code like the following:
SV mysv = newSVpv(""); SvGROW(mysv, 1024); // preallocate 1024 bytes as buffer for the re +sponse sv_setpv("Hello World\0"); some_systemcall_with_the_message_buffer( SvPV(mysv), 1024); // wri +tes the response into mysv and expects 1024 bytes to be writable
... but I'm not sure if sv_setpv is supposed to copy the string or just copy the pointer to it.
If the threshold of 64 -> 16 bytes is sensible or if the resizing should only happen for larger decrements is to be seen.
In reply to Re: [XS] sv_setpv change in behaviour with perl-5.42.0 and later
by Corion
in thread [XS] sv_setpv change in behaviour with perl-5.42.0 and later
by syphilis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |