This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change Perl_av_iter_p() to return IV* rather than I32* (which means
authorNicholas Clark <nick@ccl4.org>
Sat, 29 Dec 2007 12:28:14 +0000 (12:28 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 29 Dec 2007 12:28:14 +0000 (12:28 +0000)
having to allocate memory where sizeof(IV) > sizeof(I32)).

p4raw-id: //depot/perl@32760

av.c
embed.fnc
pp.c
proto.h

diff --git a/av.c b/av.c
index d528ffc..afca8bf 100644 (file)
--- a/av.c
+++ b/av.c
@@ -970,11 +970,18 @@ Perl_av_arylen_p(pTHX_ AV *av) {
     return &(mg->mg_obj);
 }
 
-/* This will change to returning IV ** at some point soon */
-I32 *
+IV *
 Perl_av_iter_p(pTHX_ AV *av) {
     MAGIC *const mg = get_aux_mg(av);
+#if IVSIZE == I32SIZE
     return &(mg->mg_len);
+#else
+    if (!mg->mg_ptr) {
+       mg->mg_len = IVSIZE;
+       Newxz(mg->mg_ptr, 1, IV);
+    }
+    return (IV *)mg->mg_ptr;
+#endif
 }
 
 /*
index fe09c9c..5819ad9 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -115,7 +115,7 @@ Apd |void   |av_undef       |NN AV* ar
 ApdoxM |SV**   |av_create_and_unshift_one|NN AV **const avp|NN SV *const val
 Apd    |void   |av_unshift     |NN AV* ar|I32 num
 Apo    |SV**   |av_arylen_p    |NN AV* av
-AMpo   |I32*   |av_iter_p      |NN AV* av
+Apo    |IV*    |av_iter_p      |NN AV* av
 #if defined(PERL_IN_AV_C) || defined(PERL_DECL_PROT)
 s      |MAGIC* |get_aux_mg     |NN AV *av
 #endif
diff --git a/pp.c b/pp.c
index ed3ae32..937b7ce 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -3929,7 +3929,7 @@ PP(pp_aeach)
     dSP;
     AV *array = (AV*)POPs;
     const I32 gimme = GIMME_V;
-    I32 *iterp = Perl_av_iter_p(aTHX_ array);
+    IV *iterp = Perl_av_iter_p(aTHX_ array);
     const IV current = (*iterp)++;
 
     if (current > av_len(array)) {
diff --git a/proto.h b/proto.h
index aa4d42a..a845a9a 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -189,7 +189,7 @@ PERL_CALLCONV void  Perl_av_unshift(pTHX_ AV* ar, I32 num)
 PERL_CALLCONV SV**     Perl_av_arylen_p(pTHX_ AV* av)
                        __attribute__nonnull__(pTHX_1);
 
-PERL_CALLCONV I32*     Perl_av_iter_p(pTHX_ AV* av)
+PERL_CALLCONV IV*      Perl_av_iter_p(pTHX_ AV* av)
                        __attribute__nonnull__(pTHX_1);
 
 #if defined(PERL_IN_AV_C) || defined(PERL_DECL_PROT)