than messy pointer hacks.
p4raw-id: //depot/perl@27000
test_scalar = newSV(0);
SvREFCNT_inc(test_scalar);
- victim->hent_val = test_scalar;
+ HeVAL(victim) = test_scalar;
/* Need this little game else we free the temps on the return stack. */
results[0] = SvREFCNT(test_scalar);
assert (he->shared_he_he.hent_hek == hek);
LOCK_STRTAB_MUTEX;
- if (he->shared_he_he.hent_val - 1) {
- --he->shared_he_he.hent_val;
+ if (he->shared_he_he.he_valu.hent_refcount - 1) {
+ --he->shared_he_he.he_valu.hent_refcount;
UNLOCK_STRTAB_MUTEX;
return;
}
k_flags |= HVhek_WASUTF8 | HVhek_FREEKEY;
}
- /* what follows is the moral equivalent of:
+ /* what follows was the moral equivalent of:
if ((Svp = hv_fetch(PL_strtab, tmpsv, FALSE, hash))) {
if (--*Svp == Nullsv)
hv_delete(PL_strtab, str, len, G_DISCARD, hash);
}
if (found) {
- if (--HeVAL(entry) == Nullsv) {
+ if (--he->shared_he_he.he_valu.hent_refcount == 0) {
*oentry = HeNEXT(entry);
if (!*first) {
/* There are now no entries in our slot. */
/* Still "point" to the HEK, so that other code need not know what
we're up to. */
HeKEY_hek(entry) = hek;
- HeVAL(entry) = Nullsv;
+ entry->he_valu.hent_refcount = 0;
HeNEXT(entry) = next;
*head = entry;
}
}
- ++HeVAL(entry); /* use value slot as REFCNT */
+ ++entry->he_valu.hent_refcount;
UNLOCK_STRTAB_MUTEX;
if (flags & HVhek_FREEKEY)
body arenas */
HE *hent_next; /* next entry in chain */
HEK *hent_hek; /* hash key */
- SV *hent_val; /* scalar value that was hashed */
+ union {
+ SV *hent_val; /* scalar value that was hashed */
+ Size_t hent_refcount; /* references for this shared hash key */
+ } he_valu;
};
/* hash key -- defined separately for use as shared pointer */
#define HeKREHASH(he) HEK_REHASH(HeKEY_hek(he))
#define HeKLEN_UTF8(he) (HeKUTF8(he) ? -HeKLEN(he) : HeKLEN(he))
#define HeKFLAGS(he) HEK_FLAGS(HeKEY_hek(he))
-#define HeVAL(he) (he)->hent_val
+#define HeVAL(he) (he)->he_valu.hent_val
#define HeHASH(he) HEK_HASH(HeKEY_hek(he))
#define HePV(he,lp) ((HeKLEN(he) == HEf_SVKEY) ? \
SvPV(HeKEY_sv(he),lp) : \
(++(((struct shared_he *)(((char *)hek) \
- STRUCT_OFFSET(struct shared_he, \
shared_he_hek))) \
- ->shared_he_he.hent_val), \
+ ->shared_he_he.he_valu.hent_refcount), \
hek)
/*
HE * const next = HeNEXT(hent);
Perl_warner(aTHX_ packWARN(WARN_INTERNAL),
"Unbalanced string table refcount: (%ld) for \"%s\"",
- (long)(HeVAL(hent) - Nullsv), HeKEY(hent));
+ (long)hent->he_valu.hent_refcount, HeKEY(hent));
Safefree(hent);
hent = next;
}