From: Yves Orton Date: Tue, 14 Nov 2006 00:38:31 +0000 (+0100) Subject: Fwd: Memory leak with s/// and hashes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5c9f2f80687045b87774a34dbc9e34d855fbfd1f;p=p5sagit%2Fp5-mst-13.2.git Fwd: Memory leak with s/// and hashes Message-ID: <9b18b3110611131538kc00175ft4db7ff71df22e766@mail.gmail.com> p4raw-id: //depot/perl@29268 --- diff --git a/regcomp.c b/regcomp.c index b077ddb..9099194 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4483,7 +4483,6 @@ reStudy: Newxz(r->startp, RExC_npar, I32); Newxz(r->endp, RExC_npar, I32); - DEBUG_r( RX_DEBUG_on(r) ); DEBUG_DUMP_r({ PerlIO_printf(Perl_debug_log,"Final program:\n"); regdump(r); @@ -8375,8 +8374,8 @@ Perl_pregfree(pTHX_ struct regexp *r) DEBUG_COMPILE_r({ if (!PL_colorset) reginitcolors(); - if (RX_DEBUG(r)){ - SV *dsv= sv_newmortal(); + { + SV *dsv= sv_newmortal(); RE_PV_QUOTED_DECL(s, (r->reganch & ROPT_UTF8), dsv, r->precomp, r->prelen, 60); PerlIO_printf(Perl_debug_log,"%sFreeing REx:%s %s\n", @@ -8485,12 +8484,10 @@ Perl_pregfree(pTHX_ struct regexp *r) if (trie->nextword) Safefree(trie->nextword); #ifdef DEBUGGING - if (RX_DEBUG(r)) { - if (trie->words) - SvREFCNT_dec((SV*)trie->words); - if (trie->revcharmap) - SvREFCNT_dec((SV*)trie->revcharmap); - } + if (trie->words) + SvREFCNT_dec((SV*)trie->words); + if (trie->revcharmap) + SvREFCNT_dec((SV*)trie->revcharmap); #endif Safefree(r->data->data[n]); /* do this last!!!! */ } diff --git a/regexec.c b/regexec.c index 2470821..a0637a8 100644 --- a/regexec.c +++ b/regexec.c @@ -2902,9 +2902,8 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) DEBUG_EXECUTE_r({ reg_trie_data * const trie = (reg_trie_data*)rex->data->data[ ARG(ST.me) ]; - SV ** const tmp = RX_DEBUG(reginfo->prog) - ? av_fetch( trie->words, ST.accept_buff[ 0 ].wordnum-1, 0 ) - : NULL; + SV ** const tmp = av_fetch( trie->words, + ST.accept_buff[ 0 ].wordnum-1, 0 ); PerlIO_printf( Perl_debug_log, "%*s %sonly one match left: #%d <%s>%s\n", REPORT_CODE_OFF+depth*2, "", PL_colors[4], @@ -2978,9 +2977,8 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) DEBUG_EXECUTE_r({ reg_trie_data * const trie = (reg_trie_data*)rex->data->data[ ARG(ST.me) ]; - SV ** const tmp = RX_DEBUG(reginfo->prog) - ? av_fetch( trie->words, ST.accept_buff[ best ].wordnum - 1, 0 ) - : NULL; + SV ** const tmp = av_fetch( trie->words, + ST.accept_buff[ best ].wordnum - 1, 0 ); regnode *nextop=(!ST.jump || !ST.jump[ST.accept_buff[best].wordnum]) ? ST.B : ST.me + ST.jump[ST.accept_buff[best].wordnum]; diff --git a/regexp.h b/regexp.h index f71aefa..8d08682 100644 --- a/regexp.h +++ b/regexp.h @@ -143,10 +143,6 @@ typedef struct regexp_engine { /* Stuff that needs to be included in the plugable extension goes below here */ -#define RE_DEBUG_BIT 0x20000000 -#define RX_DEBUG(prog) ((prog)->reganch & RE_DEBUG_BIT) -#define RX_DEBUG_on(prog) ((prog)->reganch |= RE_DEBUG_BIT) - #ifdef PERL_OLD_COPY_ON_WRITE #define RX_MATCH_COPY_FREE(rx) \ STMT_START {if (rx->saved_copy) { \