S_unshare_hek_or_pvn() had broken it. Now fixed and tested.
p4raw-id: //depot/perl@27761
PPCODE:
test_freeent(&Perl_hv_delayfree_ent);
XSRETURN(4);
-
+
+SV *
+test_share_unshare_pvn(input)
+ PREINIT:
+ SV *output;
+ STRLEN len;
+ U32 hash;
+ char *pvx;
+ char *p;
+ INPUT:
+ SV *input
+ CODE:
+ pvx = SvPV(input, len);
+ PERL_HASH(hash, pvx, len);
+ p = sharepvn(pvx, len, hash);
+ RETVAL = newSVpvn(p, len);
+ unsharepvn(p, len, hash);
+ OUTPUT:
+ RETVAL
+
=pod
sub TIEHASH { bless {}, $_[0] }
is_deeply([&XS::APItest::Hash::test_hv_delayfree_ent], [2,2,2,1],
"hv_delayfree_ent keeps the value around until FREETMPS");
}
+
+foreach my $in ("", "N", "a\0b") {
+ my $got = XS::APItest::Hash::test_share_unshare_pvn($in);
+ is ($got, $in, "test_share_unshare_pvn");
+}
+
exit;
################################ The End ################################
HE *entry;
register HE **oentry;
HE **first;
- bool found = 0;
bool is_utf8 = FALSE;
int k_flags = 0;
const char * const save = str;
if (he) {
const HE *const he_he = &(he->shared_he_he);
for (entry = *oentry; entry; oentry = &HeNEXT(entry), entry = *oentry) {
- if (entry != he_he)
- continue;
- found = 1;
- break;
+ if (entry == he_he)
+ break;
}
} else {
const int flags_masked = k_flags & HVhek_MASK;
continue;
if (HeKFLAGS(entry) != flags_masked)
continue;
- found = 1;
break;
}
}
- if (found) {
- if (--he->shared_he_he.he_valu.hent_refcount == 0) {
+ if (entry) {
+ if (--entry->he_valu.hent_refcount == 0) {
*oentry = HeNEXT(entry);
if (!*first) {
/* There are now no entries in our slot. */
}
UNLOCK_STRTAB_MUTEX;
- if (!found && ckWARN_d(WARN_INTERNAL))
+ if (!entry && ckWARN_d(WARN_INTERNAL))
Perl_warner(aTHX_ packWARN(WARN_INTERNAL),
"Attempt to free non-existent shared string '%s'%s"
pTHX__FORMAT,