This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
patch for more flexible initialization of xsub parameters
[perl5.git] / av.h
diff --git a/av.h b/av.h
index 56b6e32..8de81f4 100644 (file)
--- a/av.h
+++ b/av.h
@@ -1,6 +1,6 @@
 /*    av.h
  *
- *    Copyright (c) 1991-1994, Larry Wall
+ *    Copyright (c) 1991-1998, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -8,15 +8,15 @@
  */
 
 struct xpvav {
-    char*      xav_array;      /* pointer to malloced string */
-    SSize_t    xav_fill;
-    SSize_t    xav_max;
+    char*      xav_array;      /* pointer to first array element */
+    SSize_t    xav_fill;       /* Index of last element present */
+    SSize_t    xav_max;        /* Number of elements for which array has space */
     IV         xof_off;        /* ptr is incremented by offset */
     double     xnv_nv;         /* numeric value, if any */
     MAGIC*     xmg_magic;      /* magic for scalar array */
     HV*                xmg_stash;      /* class package */
 
-    SV**       xav_alloc;
+    SV**       xav_alloc;      /* pointer to malloced string */
     SV*                xav_arylen;
     U8         xav_flags;
 };
@@ -30,7 +30,7 @@ struct xpvav {
 #define AvARRAY(av)    ((SV**)((XPVAV*)  SvANY(av))->xav_array)
 #define AvALLOC(av)    ((XPVAV*)  SvANY(av))->xav_alloc
 #define AvMAX(av)      ((XPVAV*)  SvANY(av))->xav_max
-#define AvFILL(av)     ((XPVAV*)  SvANY(av))->xav_fill
+#define AvFILLp(av)    ((XPVAV*)  SvANY(av))->xav_fill
 #define AvARYLEN(av)   ((XPVAV*)  SvANY(av))->xav_arylen
 #define AvFLAGS(av)    ((XPVAV*)  SvANY(av))->xav_flags
 
@@ -45,4 +45,7 @@ struct xpvav {
 #define AvREUSED_off(av) (AvFLAGS(av) &= ~AVf_REUSED)
 
 #define AvREALISH(av)  (AvFLAGS(av) & (AVf_REAL|AVf_REIFY))
+                                          
+#define AvFILL(av)     ((SvRMAGICAL((SV *) (av))) \
+                         ? mg_size((SV *) av) : AvFILLp(av))