In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/d09f14bff00cc465825c16e4e810687132f34070?hp=f63f40368cca0cfffd2773a6206d1ab3235b61b3>
- Log ----------------------------------------------------------------- commit d09f14bff00cc465825c16e4e810687132f34070 Author: Zefram <[email protected]> Date: Mon Nov 13 07:52:35 2017 +0000 avoid redundant initialisation around Newxz() Reduce Newxz() to Newx() where all relevant parts of the memory are being explicitly initialised, and don't explicitly zero memory that was already zeroed. [perl #36078] commit 8f9371749363490230e8a3114a27b7f29d52f12e Author: Zefram <[email protected]> Date: Mon Nov 13 07:49:13 2017 +0000 remove unused struct member "is_top_frame" commit e8b20b1238fb2bfcdc6d131e979cbd6c1dbd4b71 Author: Zefram <[email protected]> Date: Mon Nov 13 07:45:35 2017 +0000 duplicate full index for SAVEt_AELEM The index in a SAVEt_AELEM save entry is now IV-sized, but only an I32 portion of it was being duplicated. This would lead to restoring the wrong element if a pseudfork were done with a localised array element on the stack, if the array index were above the 32-bit range or on a big-endian architecture. ----------------------------------------------------------------------- Summary of changes: perlio.c | 2 +- regcomp.c | 17 ++++++++--------- sv.c | 27 +++++++++++---------------- toke.c | 6 ++++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/perlio.c b/perlio.c index 054f210e37..e7dd7f5f18 100644 --- a/perlio.c +++ b/perlio.c @@ -4281,7 +4281,7 @@ PerlIOBuf_get_base(pTHX_ PerlIO *f) if (!b->buf) { if (!b->bufsiz) b->bufsiz = PERLIOBUF_DEFAULT_BUFSIZ; - Newxz(b->buf,b->bufsiz, STDCHAR); + Newx(b->buf,b->bufsiz, STDCHAR); if (!b->buf) { b->buf = (STDCHAR *) & b->oneword; b->bufsiz = sizeof(b->oneword); diff --git a/regcomp.c b/regcomp.c index 9aec81ddfa..842094a961 100644 --- a/regcomp.c +++ b/regcomp.c @@ -110,7 +110,6 @@ typedef struct scan_frame { regnode *next_regnode; /* next node to process when last is reached */ U32 prev_recursed_depth; I32 stopparen; /* what stopparen do we use */ - U32 is_top_frame; /* what flags do we use? */ struct scan_frame *this_prev_frame; /* this previous frame */ struct scan_frame *prev_frame; /* previous frame */ @@ -1118,7 +1117,7 @@ PERL_STATIC_INLINE item* push(UV key,item* curr) { item* head; - Newxz(head, 1, item); + Newx(head, 1, item); head->key = key; head->value = 0; head->next = curr; @@ -1188,7 +1187,7 @@ S_edit_distance(const UV* src, PERL_ARGS_ASSERT_EDIT_DISTANCE; /* intialize matrix start values */ - Newxz(scores, ( (x + 2) * (y + 2)), UV); + Newx(scores, ( (x + 2) * (y + 2)), UV); scores[0] = score_ceil; scores[1 * (y + 2) + 0] = score_ceil; scores[0 * (y + 2) + 1] = score_ceil; @@ -2423,7 +2422,7 @@ is the recommended Unicode-aware way of saying } STMT_END #define TRIE_LIST_NEW(state) STMT_START { \ - Newxz( trie->states[ state ].trans.list, \ + Newx( trie->states[ state ].trans.list, \ 4, reg_trie_trans_le ); \ TRIE_LIST_CUR( state ) = 1; \ TRIE_LIST_LEN( state ) = 4; \ @@ -3618,7 +3617,7 @@ S_construct_ahocorasick_from_trie(pTHX_ RExC_state_t *pRExC_state, regnode *sour aho->trie=trie_offset; aho->states=(reg_trie_state *)PerlMemShared_malloc( numstates * sizeof(reg_trie_state) ); Copy( trie->states, aho->states, numstates, reg_trie_state ); - Newxz( q, numstates, U32); + Newx( q, numstates, U32); aho->fail = (U32 *) PerlMemShared_calloc( numstates, sizeof(U32) ); aho->refcount = 1; fail = aho->fail; @@ -7373,7 +7372,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, 3-units-long substrs field. */ Newx(r->substrs, 1, struct reg_substr_data); if (RExC_recurse_count) { - Newxz(RExC_recurse,RExC_recurse_count,regnode *); + Newx(RExC_recurse,RExC_recurse_count,regnode *); SAVEFREEPV(RExC_recurse); } @@ -7755,7 +7754,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count, if (RExC_seen & REG_RECURSE_SEEN ) { r->intflags |= PREGf_RECURSE_SEEN; - Newxz(r->recurse_locinput, r->nparens + 1, char *); + Newx(r->recurse_locinput, r->nparens + 1, char *); } if (RExC_seen & REG_GPOS_SEEN) r->intflags |= PREGf_GPOS_SEEN; @@ -19642,7 +19641,7 @@ Perl_reg_temp_copy(pTHX_ REGEXP *dsv, REGEXP *ssv) drx->mother_re = ReREFCNT_inc(srx->mother_re ? srx->mother_re : ssv); SvREFCNT_inc_void(drx->qr_anoncv); if (srx->recurse_locinput) - Newxz(drx->recurse_locinput,srx->nparens + 1,char *); + Newx(drx->recurse_locinput,srx->nparens + 1,char *); return dsv; } @@ -19852,7 +19851,7 @@ Perl_re_dup_guts(pTHX_ const REGEXP *sstr, REGEXP *dstr, CLONE_PARAMS *param) RXp_PAREN_NAMES(ret) = hv_dup_inc(RXp_PAREN_NAMES(ret), param); ret->qr_anoncv = MUTABLE_CV(sv_dup_inc((const SV *)ret->qr_anoncv, param)); if (r->recurse_locinput) - Newxz(ret->recurse_locinput,r->nparens + 1,char *); + Newx(ret->recurse_locinput,r->nparens + 1,char *); if (ret->pprivate) RXi_SET(ret,CALLREGDUPE_PVT(dstr,param)); diff --git a/sv.c b/sv.c index c1a33fb0a0..bf0b153359 100644 --- a/sv.c +++ b/sv.c @@ -13503,13 +13503,6 @@ Perl_parser_dup(pTHX_ const yy_parser *const proto, CLONE_PARAMS *const param) Newxz(parser, 1, yy_parser); ptr_table_store(PL_ptr_table, proto, parser); - /* XXX these not yet duped */ - parser->old_parser = NULL; - parser->stack = NULL; - parser->ps = NULL; - parser->stack_max1 = 0; - /* XXX parser->stack->state = 0; */ - /* XXX eventually, just Copy() most of the parser struct ? */ parser->lex_brackets = proto->lex_brackets; @@ -13551,7 +13544,6 @@ Perl_parser_dup(pTHX_ const yy_parser *const proto, CLONE_PARAMS *const param) parser->sig_optelems= proto->sig_optelems; parser->sig_slurpy = proto->sig_slurpy; parser->recheck_utf8_validity = proto->recheck_utf8_validity; - parser->linestr = sv_dup_inc(proto->linestr, param); { char * const ols = SvPVX(proto->linestr); @@ -14347,7 +14339,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) SSize_t items = AvFILLp((const AV *)sstr) + 1; src_ary = AvARRAY((const AV *)sstr); - Newxz(dst_ary, AvMAX((const AV *)sstr)+1, SV*); + Newx(dst_ary, AvMAX((const AV *)sstr)+1, SV*); ptr_table_store(PL_ptr_table, src_ary, dst_ary); AvARRAY(MUTABLE_AV(dstr)) = dst_ary; AvALLOC((const AV *)dstr) = dst_ary; @@ -14679,7 +14671,7 @@ Perl_si_dup(pTHX_ PERL_SI *si, CLONE_PARAMS* param) return nsi; /* create anew and remember what it is */ - Newxz(nsi, 1, PERL_SI); + Newx(nsi, 1, PERL_SI); ptr_table_store(PL_ptr_table, si, nsi); nsi->si_stack = av_dup_inc(si->si_stack, param); @@ -14690,6 +14682,9 @@ Perl_si_dup(pTHX_ PERL_SI *si, CLONE_PARAMS* param) nsi->si_prev = si_dup(si->si_prev, param); nsi->si_next = si_dup(si->si_next, param); nsi->si_markoff = si->si_markoff; +#if defined DEBUGGING && !defined DEBUGGING_RE_ONLY + nsi->si_stack_hwm = 0; +#endif return nsi; } @@ -14771,7 +14766,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) PERL_ARGS_ASSERT_SS_DUP; - Newxz(nss, max, ANY); + Newx(nss, max, ANY); while (ix > 0) { const UV uv = POPUV(ss,ix); @@ -14974,8 +14969,8 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) case SAVEt_AELEM: /* array element */ sv = (const SV *)POPPTR(ss,ix); TOPPTR(nss,ix) = SvREFCNT_inc(sv_dup_inc(sv, param)); - i = POPINT(ss,ix); - TOPINT(nss,ix) = i; + iv = POPIV(ss,ix); + TOPIV(nss,ix) = iv; av = (const AV *)POPPTR(ss,ix); TOPPTR(nss,ix) = av_dup_inc(av, param); break; @@ -15734,7 +15729,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, /* next PUSHMARK() sets *(PL_markstack_ptr+1) */ i = proto_perl->Imarkstack_max - proto_perl->Imarkstack; - Newxz(PL_markstack, i, I32); + Newx(PL_markstack, i, I32); PL_markstack_max = PL_markstack + (proto_perl->Imarkstack_max - proto_perl->Imarkstack); PL_markstack_ptr = PL_markstack + (proto_perl->Imarkstack_ptr @@ -15744,11 +15739,11 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, /* next push_scope()/ENTER sets PL_scopestack[PL_scopestack_ix] * NOTE: unlike the others! */ - Newxz(PL_scopestack, PL_scopestack_max, I32); + Newx(PL_scopestack, PL_scopestack_max, I32); Copy(proto_perl->Iscopestack, PL_scopestack, PL_scopestack_ix, I32); #ifdef DEBUGGING - Newxz(PL_scopestack_name, PL_scopestack_max, const char *); + Newx(PL_scopestack_name, PL_scopestack_max, const char *); Copy(proto_perl->Iscopestack_name, PL_scopestack_name, PL_scopestack_ix, const char *); #endif /* reset stack AV to correct length before its duped via diff --git a/toke.c b/toke.c index 3dd4b47470..4cdfcea7d9 100644 --- a/toke.c +++ b/toke.c @@ -10078,8 +10078,9 @@ S_scan_heredoc(pTHX_ char *s) /* No whitespace or all! */ if (backup == s || *backup == '\n') { - Newxz(indent, indent_len + 1, char); + Newx(indent, indent_len + 1, char); memcpy(indent, backup + 1, indent_len); + indent[indent_len] = 0; s--; /* before our delimiter */ PL_parser->herelines--; /* this line doesn't count */ break; @@ -10213,8 +10214,9 @@ S_scan_heredoc(pTHX_ char *s) /* All whitespace or none! */ if (backup == found || SPACE_OR_TAB(*backup)) { - Newxz(indent, indent_len + 1, char); + Newx(indent, indent_len + 1, char); memcpy(indent, backup, indent_len); + indent[indent_len] = 0; SvREFCNT_dec(PL_linestr); PL_linestr = linestr_save; PL_linestart = SvPVX(linestr_save); -- Perl5 Master Repository
