From: Nicholas Clark Date: Fri, 30 Dec 2005 15:55:05 +0000 (+0000) Subject: Now that the backreference array has no NULL entries, and is correctly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d7cbc7b5c258cffaf362ecafb36c5dfc354c1ffa;p=p5sagit%2Fp5-mst-13.2.git Now that the backreference array has no NULL entries, and is correctly marked as AvREAL_off(), there's no reason not to use sv_dup to clone it. p4raw-id: //depot/perl@26541 --- diff --git a/sv.c b/sv.c index f377c59..3e3bb18 100644 --- a/sv.c +++ b/sv.c @@ -9076,16 +9076,9 @@ Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS* param) nmg->mg_obj = (SV*)re_dup((REGEXP*)mg->mg_obj, param); } else if(mg->mg_type == PERL_MAGIC_backref) { - const AV * const av = (AV*) mg->mg_obj; - SV **svp; - I32 i; - (void)SvREFCNT_inc(nmg->mg_obj = (SV*)newAV()); - AvREAL_off((AV*)nmg->mg_obj); - svp = AvARRAY(av); - for (i = AvFILLp(av); i >= 0; i--) { - if (!svp[i]) continue; - av_push((AV*)nmg->mg_obj,sv_dup(svp[i],param)); - } + /* The backref AV has its reference count deliberately bumped by + 1. */ + nmg->mg_obj = SvREFCNT_inc(av_dup_inc((AV*) mg->mg_obj, param)); } else if (mg->mg_type == PERL_MAGIC_symtab) { nmg->mg_obj = mg->mg_obj;