Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using readonly C literals in read write SVs without a croak "Modification of a read-only"

5 views
Skip to first unread message

bulk88

unread,
Nov 14, 2012, 10:38:00 PM11/14/12
to perl5-...@perl.org
There is the SvLEN = 0 and SVf_POK means not perl alloced PV and I can
use static char arrays. If I add SVf_READONLY I can use static const
char C literals. These 2 I assume are possible today right?

Now, what if I want a SV to contain a static const char C literal PV,
but not croak with a no modify if an attempt is made to change the SV?

There is "if (SvTHINKFIRST(gv)) sv_force_normal(gv);" which will remove
SVf_READONLY, drop COWs and do "other" things to prevent a croak no
modify, right? Is there a way to use a static const char C literal PV
but have it go away and be replaced with a perl alloced PV (probably by
sv_force_normal) if something wants to write to the SV transparently or
using a HEK/newSVpvn_share the only way to do what I am thinking?

The theme here is reduce perl's pattern of making unconditional on
interp startup malloced copies of C literals to reduce the process
specific memory size of perl.
0 new messages