This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Correct the paramter to Perl_op_xmldump(). The one that got away from
[perl5.git] / av.c
diff --git a/av.c b/av.c
index 07d8e22..343274f 100644 (file)
--- a/av.c
+++ b/av.c
@@ -1,7 +1,7 @@
 /*    av.c
  *
  *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
+ *    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -77,7 +77,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key)
        PUSHMARK(SP);
        EXTEND(SP,2);
        PUSHs(SvTIED_obj((SV*)av, mg));
-       PUSHs(sv_2mortal(newSViv(key+1)));
+       mPUSHi(key + 1);
         PUTBACK;
        call_method("EXTEND", G_SCALAR|G_DISCARD);
        POPSTACK;
@@ -355,25 +355,6 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val)
 }
 
 /*
-=for apidoc newAV
-
-Creates a new AV.  The reference count is set to 1.
-
-=cut
-*/
-
-AV *
-Perl_newAV(pTHX)
-{
-    register AV * const av = (AV*)newSV_type(SVt_PVAV);
-    /* sv_upgrade does AvREAL_only()  */
-    AvALLOC(av) = 0;
-    AvARRAY(av) = NULL;
-    AvMAX(av) = AvFILLp(av) = -1;
-    return av;
-}
-
-/*
 =for apidoc av_make
 
 Creates a new AV and populates it with a list of SVs.  The SVs are copied
@@ -781,7 +762,7 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill)
        PUSHMARK(SP);
        EXTEND(SP,2);
        PUSHs(SvTIED_obj((SV*)av, mg));
-       PUSHs(sv_2mortal(newSViv(fill+1)));
+       mPUSHi(fill + 1);
        PUTBACK;
        call_method("STORESIZE", G_SCALAR|G_DISCARD);
        POPSTACK;
@@ -964,8 +945,8 @@ Perl_av_exists(pTHX_ AV *av, I32 key)
        return FALSE;
 }
 
-SV **
-Perl_av_arylen_p(pTHX_ AV *av) {
+MAGIC *
+S_get_aux_mg(pTHX_ AV *av) {
     dVAR;
     MAGIC *mg;
 
@@ -980,9 +961,31 @@ Perl_av_arylen_p(pTHX_ AV *av) {
        /* sv_magicext won't set this for us because we pass in a NULL obj  */
        mg->mg_flags |= MGf_REFCOUNTED;
     }
+    return mg;
+}
+
+SV **
+Perl_av_arylen_p(pTHX_ AV *av) {
+    MAGIC *const mg = get_aux_mg(av);
     return &(mg->mg_obj);
 }
 
+IV *
+Perl_av_iter_p(pTHX_ AV *av) {
+    MAGIC *const mg = get_aux_mg(av);
+#if IVSIZE == I32SIZE
+    return (IV *)&(mg->mg_len);
+#else
+    if (!mg->mg_ptr) {
+       IV *temp;
+       mg->mg_len = IVSIZE;
+       Newxz(temp, 1, IV);
+       mg->mg_ptr = (char *) temp;
+    }
+    return (IV *)mg->mg_ptr;
+#endif
+}
+
 /*
  * Local variables:
  * c-indentation-style: bsd