]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add FETCHSIZE function to Perl tied arrays
authorNick Porter <nick@portercomputing.co.uk>
Thu, 15 May 2025 15:45:14 +0000 (16:45 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 19 May 2025 09:52:34 +0000 (10:52 +0100)
src/modules/rlm_perl/rlm_perl.c

index 3bfcca617fa21a752707bdc8d6a3b7692c16fcb9..ec5f6a8de3451643420dfced66e19be9e9c8cdec 100644 (file)
@@ -853,6 +853,19 @@ static XS(XS_pairs_DELETE)
        XSRETURN(0);
 }
 
+/** Called when Perl wants the size of a tied array
+ *
+ * The stack contains just the tied SV
+ */
+static XS(XS_pairs_FETCHSIZE)
+{
+       dXSARGS;
+       GET_PAIR_MAGIC(1)
+
+       if (!pair_data->parent->vp) XSRETURN_UV(0);
+       XSRETURN_UV(fr_pair_count_by_da(&pair_data->parent->vp->vp_group, pair_data->da));
+}
+
 static void xs_init(pTHX)
 {
        char const *file = __FILE__;
@@ -882,6 +895,7 @@ static void xs_init(pTHX)
        newXS("freeradiuspairs::STORE", XS_pairs_STORE, "rlm_perl");
        newXS("freeradiuspairs::EXISTS", XS_pairs_EXISTS, "rlm_perl");
        newXS("freeradiuspairs::DELETE", XS_pairs_DELETE, "rlm_perl");
+       newXS("freeradiuspairs::FETCHSIZE", XS_pairs_FETCHSIZE, "rlm_perl");
 }
 
 /** Convert a list of value boxes to a Perl array for passing to subroutines