1 ################################################################################
3 ## Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
4 ## Version 2.x, Copyright (C) 2001, Paul Marquess.
5 ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
7 ## This program is free software; you can redistribute it and/or
8 ## modify it under the same terms as Perl itself.
10 ################################################################################
19 /* Hint: newSVpvn_share
20 * The SVs created by this function only mimic the behaviour of
21 * shared PVs without really being shared. Only use if you know
25 #ifndef newSVpvn_share
27 #if { NEED newSVpvn_share }
30 newSVpvn_share(pTHX_ const char *s, I32 len, U32 hash)
36 PERL_HASH(hash, (char*) s, len);
37 sv = newSVpvn((char *) s, len);
38 sv_upgrade(sv, SVt_PVIV);
49 __UNDEFINED__ SvSHARED_HASH(sv) (0 + SvUVX(sv))
53 #define NEED_newSVpvn_share
68 PERL_HASH(hash, (char *) s, len);
69 sv = newSVpvn_share(s, len, 0);
71 RETVAL += strEQ(SvPV_nolen_const(sv), "mhx");
72 RETVAL += SvCUR(sv) == len;
73 RETVAL += SvSHARED_HASH(sv) == hash;
77 PERL_HASH(hash, (char *) s, len);
78 sv = newSVpvn_share(s, -(I32) len, hash);
80 RETVAL += strEQ(SvPV_nolen_const(sv), "foobar");
81 RETVAL += SvCUR(sv) == len;
82 RETVAL += SvSHARED_HASH(sv) == hash;
90 is(&Devel::PPPort::newSVpvn_share(), 6);