Change 19867 by [EMAIL PROTECTED] on 2003/06/27 10:08:20
The two-for-loops is no more a valid way to walk through
a hash (this was the reason the Hash/Util.t intermittently
failed, the two-loop didn't find all the SVs of the HV).
Affected files ...
... //depot/perl/hv.c#133 edit
Differences ...
==== //depot/perl/hv.c#133 (text) ====
Index: perl/hv.c
--- perl/hv.c#132~19632~ Thu May 29 01:12:46 2003
+++ perl/hv.c Fri Jun 27 03:08:20 2003
@@ -1705,27 +1705,29 @@
xhv = (XPVHV*)SvANY(hv);
- if(SvREADONLY(hv)) {
+ if (SvREADONLY(hv)) {
/* restricted hash: convert all keys to placeholders */
- I32 i;
- HE* entry;
- for (i=0; i< (I32) xhv->xhv_max; i++) {
- entry = ((HE**)xhv->xhv_array)[i];
- for (; entry; entry = HeNEXT(entry)) {
- /* not already placeholder */
- if (HeVAL(entry) != &PL_sv_undef) {
- if (HeVAL(entry) && SvREADONLY(HeVAL(entry))) {
- SV* keysv = hv_iterkeysv(entry);
- Perl_croak(aTHX_
- "Attempt to delete readonly key '%"SVf"' from a restricted hash",
- keysv);
- }
- SvREFCNT_dec(HeVAL(entry));
- HeVAL(entry) = &PL_sv_undef;
- xhv->xhv_placeholders++; /* HvPLACEHOLDERS(hv)++ */
- }
+ HE* he;
+
+ hv_iterinit(hv);
+ while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS))) {
+ SV *val;
+
+ val = hv_iterval(hv, he);
+ if (val != &PL_sv_undef) { /* not already placeholder */
+ if (val && SvREADONLY(val)) {
+ SV* keysv = hv_iterkeysv(he);
+
+ Perl_croak(aTHX_
+ "Attempt to delete readonly key '%"SVf"' from a
restricted hash",
+ keysv);
+ }
+ SvREFCNT_dec(val);
+ HeVAL(he) = &PL_sv_undef;
+ xhv->xhv_placeholders++; /* HvPLACEHOLDERS(hv)++ */
}
}
+ hv_iterinit(hv);
return;
}
End of Patch.